CreateTableAsSelect Logical Command¶
CreateTableAsSelect
is a BinaryCommand
with V2CreateTablePlan that represents the following high-level operators in a logical query plan:
- CREATE TABLE AS SELECT SQL statement
- DataFrameWriter.save
- DataFrameWriter.saveAsTable
- DataFrameWriterV2.create
CreateTableAsSelect
is planned as AtomicCreateTableAsSelectExec
or CreateTableAsSelectExec physical command at execution.
Creating Instance¶
CreateTableAsSelect
takes the following to be created:
- Name LogicalPlan
- Partitioning Transforms
- Query LogicalPlan
-
TableSpec
- Write Options
-
ignoreIfExists
flag
CreateTableAsSelect
is created when:
AstBuilder
is requested to parse CREATE TABLE SQL statement (CREATE TABLE AS SELECT (CTAS))DataFrameWriter
is requested to save (and saveInternal) and saveAsTableDataFrameWriterV2
is requested to create a table
Execution Planning¶
CreateTableAsSelect
is planned to one of the following by DataSourceV2Strategy execution planning strategy (based on a CatalogPlugin this CreateTableAsSelect
is executed against):
AtomicCreateTableAsSelectExec
unary physical command on a StagingTableCatalog- CreateTableAsSelectExec physical command, otherwise
(Legacy) Logical Resolution¶
CreateTableAsSelect
can be resolved to a CreateTableV1
logical operator by ResolveSessionCatalog logical resolution rule (for non-isV2Provider legacy providers).