We are going to add "PARTITION BY" clause in Drill's CTAS statement. The "PARTITION BY" clause will specify the list of columns out of the result table's column list that will be used to partition the data.
CREATE TABLE table_name [ (col_name, .... ) ]
[PARTITION BY (col_name, ...)]
Semantics restriction for the PARTITION BY clause:
- All the columns in the PARTITION BY clause have to be in the table's column list, or the SELECT_STATEMENT has a * column, when the base table in the SELECT_STATEMENT is schema-less. Otherwise, an query validation error would be raised.
- When the partition column is resolved to * column in a schema-less query, this * column could not be a result of join operation. This restriction is added, since for * out of join operation, query planner would not know which table might produce this partition column.
Invalid case 1: Partition column is not in table's column list.
Invalid case 2: Partition column is resolved to * out of a join operator.