CreateTable Logical Operator¶
CreateTable
is a logical operator that represents (is <
-
DataFrameWriter
is requested to create a table (for DataFrameWriter.saveAsTable operator) -
SparkSqlAstBuilder
is requested to visitCreateTable (forCREATE TABLE
SQL command) or visitCreateHiveTable (forCREATE EXTERNAL TABLE
SQL command) -
CatalogImpl
is requested to create a table (for Catalog.createTable operator)
CreateTable
requires that the table provider of the CatalogTable is defined or throws an AssertionError
:
assertion failed: The table to be created must have a provider.
The optional <
-
DataFrameWriter
is requested to create a table (for DataFrameWriter.saveAsTable operator) -
SparkSqlAstBuilder
is requested to visitCreateTable (forCREATE TABLE
SQL command) or visitCreateHiveTable (forCREATE EXTERNAL TABLE
SQL command) with an AS clause
[[resolved]] CreateTable
can never be resolved and is replaced (resolved) with a logical command at analysis phase in the following rules:
-
(for non-hive data source tables) DataSourceAnalysis posthoc logical resolution rule to a <
> or a < > logical command (when the < > was defined or not, respectively) -
(for hive tables) hive/HiveAnalysis.md[HiveAnalysis] post-hoc logical resolution rule to a
CreateTableCommand
or a CreateHiveTableAsSelectCommand logical command (when <> was defined or not, respectively)
=== [[creating-instance]] Creating CreateTable Instance
CreateTable
takes the following to be created:
- [[tableDesc]] Table metadata
- [[mode]] SaveMode
- [[query]] Optional AS query (Logical query plan)
When created, CreateTable
makes sure that the optional <ErrorIfExists
or Ignore
. CreateTable
throws an AssertionError
otherwise:
assertion failed: create table without data insertion can only use ErrorIfExists or Ignore as SaveMode.