assertion failed: The table to be created must have a provider.
CreateTable Logical Operator
CreateTable
is a logical operator that represents (is created for) the following:
-
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
:
The optional AS query is defined when used for the following:
-
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
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 CreateDataSourceTableCommand or a CreateDataSourceTableAsSelectCommand logical command (when the query was defined or not, respectively)
-
(for hive tables) HiveAnalysis post-hoc logical resolution rule to a CreateTableCommand or a CreateHiveTableAsSelectCommand logical command (when query was defined or not, respectively)
Creating CreateTable Instance
CreateTable
takes the following to be created:
-
Optional AS query (Logical query plan)
When created, CreateTable
makes sure that the optional logical query plan is undefined only when the mode is ErrorIfExists
or Ignore
. CreateTable
throws an AssertionError
otherwise:
assertion failed: create table without data insertion can only use ErrorIfExists or Ignore as SaveMode.