|
30 | 30 | import java.util.List; |
31 | 31 | import java.util.Set; |
32 | 32 |
|
| 33 | +/** |
| 34 | + * Interface for COPY TO command options. |
| 35 | + * |
| 36 | + * <p>This interface defines the configuration for COPY TO operations, including target format, |
| 37 | + * target table name, column mappings, and memory management. Implementations provide |
| 38 | + * format-specific validation and inference logic. |
| 39 | + */ |
33 | 40 | public interface CopyToOptions extends Accountable { |
34 | 41 |
|
| 42 | + /** |
| 43 | + * Infers and validates options based on query analysis and relation plan. |
| 44 | + * |
| 45 | + * <p>This method is called during analysis phase to fill in default values and validate |
| 46 | + * user-specified options against the query structure. For example, it can infer the target time |
| 47 | + * column from the query's time column if not explicitly specified. |
| 48 | + * |
| 49 | + * @param analysis the query analysis containing metadata about the query |
| 50 | + * @param queryRelationPlan the logical relation plan of the inner query |
| 51 | + * @param columnHeaders the column headers from the query result |
| 52 | + */ |
35 | 53 | void infer(Analysis analysis, RelationPlan queryRelationPlan, List<ColumnHeader> columnHeaders); |
36 | 54 |
|
| 55 | + /** |
| 56 | + * Validates the options against the actual column schema. |
| 57 | + * |
| 58 | + * <p>This method is called after planning to ensure the specified options (e.g., target columns, |
| 59 | + * tags) are valid for the given output schema. |
| 60 | + * |
| 61 | + * @param columnHeaders the column headers of the query result |
| 62 | + * @throws SemanticException if validation fails |
| 63 | + */ |
37 | 64 | void check(List<ColumnHeader> columnHeaders); |
38 | 65 |
|
| 66 | + /** |
| 67 | + * Returns the response column headers for the result set. |
| 68 | + * |
| 69 | + * <p>These headers describe the columns that will be returned to the client after the COPY TO |
| 70 | + * operation completes (e.g., file path, row count). |
| 71 | + * |
| 72 | + * @return list of column headers for the response |
| 73 | + */ |
39 | 74 | List<ColumnHeader> getRespColumnHeaders(); |
40 | 75 |
|
| 76 | + /** |
| 77 | + * Returns the target output format. |
| 78 | + * |
| 79 | + * @return the format enum value |
| 80 | + */ |
41 | 81 | Format getFormat(); |
42 | 82 |
|
| 83 | + /** |
| 84 | + * Estimates the maximum memory usage in bytes required for writing. |
| 85 | + * |
| 86 | + * <p>This is used for memory management and determining whether to flush data to disk. |
| 87 | + * |
| 88 | + * @return estimated maximum memory usage in bytes |
| 89 | + */ |
43 | 90 | long estimatedMaxRamBytesInWrite(); |
44 | 91 |
|
| 92 | + /** Supported output formats for COPY TO command. */ |
45 | 93 | enum Format { |
| 94 | + /** TsFile format output. */ |
46 | 95 | TSFILE, |
47 | 96 | } |
48 | 97 |
|
|
0 commit comments