Skip to content

Commit 85c9a22

Browse files
CreateTable Logical Operator
1 parent 71736c0 commit 85c9a22

File tree

1 file changed

+17
-36
lines changed

1 file changed

+17
-36
lines changed

docs/logical-operators/CreateTable.md

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ title: CreateTable
66

77
`CreateTable` is a [LogicalPlan](LogicalPlan.md).
88

9+
## Analysis Phase
10+
11+
`CreateTable` can never be [resolved](#resolved) and is replaced with (_resolved to_) a logical command at analysis phase in the following rules:
12+
13+
* (for non-hive data source tables) [DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md) posthoc logical resolution rule to a [CreateDataSourceTableCommand](CreateDataSourceTableCommand.md) or a [CreateDataSourceTableAsSelectCommand](CreateDataSourceTableAsSelectCommand.md) logical command (based on the [query](#query) defined or not, respectively)
14+
15+
* (for hive tables) [HiveAnalysis](../hive/HiveAnalysis.md) post-hoc logical resolution rule to a `CreateTableCommand` or a [CreateHiveTableAsSelectCommand](../hive/CreateHiveTableAsSelectCommand.md) logical command (based on the [query](#query) defined or not, respectively)
16+
917
## Creating Instance
1018

1119
`CreateTable` takes the following to be created:
@@ -17,48 +25,21 @@ title: CreateTable
1725
While being created, `CreateTable` asserts the following:
1826

1927
* The [table](#tableDesc) to be created must have the [provider](../CatalogTable.md#provider)
20-
* With no [query](#query), the [SaveMode](#mode) must be `ErrorIfExists` or `Ignore`
28+
* With no [query](#query), the [SaveMode](#mode) must be either `ErrorIfExists` or `Ignore`
2129

2230
`CreateTable` is created when:
2331

24-
* [DataFrameWriter.saveAsTable](../DataFrameWriter.md#saveAsTable) operator is used (to [create a table](../DataFrameWriter.md#createTable))
32+
* [DataFrameWriter.saveAsTable](../DataFrameWriter.md#saveAsTable) operator is used (and [creates a table](../DataFrameWriter.md#createTable))
2533
* [ResolveSessionCatalog](../logical-analysis-rules/ResolveSessionCatalog.md) logical resolution rule is executed (to [constructV1TableCmd](../logical-analysis-rules/ResolveSessionCatalog.md#constructV1TableCmd))
2634

27-
<!---
28-
## Review Me
29-
30-
`CreateTable` is a [logical operator](LogicalPlan.md) that represents (is <<creating-instance, created>> for) the following:
31-
32-
* `DataFrameWriter` is requested to [create a table](../DataFrameWriter.md#createTable) (for [DataFrameWriter.saveAsTable](../DataFrameWriter.md#saveAsTable) operator)
33-
34-
* `SparkSqlAstBuilder` is requested to [visitCreateTable](../sql/SparkSqlAstBuilder.md#visitCreateTable) (for `CREATE TABLE` SQL command) or [visitCreateHiveTable](../sql/SparkSqlAstBuilder.md#visitCreateHiveTable) (for `CREATE EXTERNAL TABLE` SQL command)
35-
36-
* `CatalogImpl` is requested to [create a table](../CatalogImpl.md#createTable) (for [Catalog.createTable](../Catalog.md#createTable) operator)
35+
## Never Resolved { #resolved }
3736

38-
`CreateTable` requires that the [table provider](../CatalogTable.md#provider) of the [CatalogTable](#tableDesc) is defined or throws an `AssertionError`:
37+
??? note "LogicalPlan"
3938

40-
```text
41-
assertion failed: The table to be created must have a provider.
42-
```
39+
```scala
40+
resolved: Boolean
41+
```
4342

44-
The optional <<query, AS query>> is defined when used for the following:
45-
46-
* `DataFrameWriter` is requested to [create a table](../DataFrameWriter.md#createTable) (for [DataFrameWriter.saveAsTable](../DataFrameWriter.md#saveAsTable) operator)
47-
48-
* `SparkSqlAstBuilder` is requested to [visitCreateTable](../sql/SparkSqlAstBuilder.md#visitCreateTable) (for `CREATE TABLE` SQL command) or [visitCreateHiveTable](../sql/SparkSqlAstBuilder.md#visitCreateHiveTable) (for `CREATE EXTERNAL TABLE` SQL command) with an AS clause
49-
50-
[[resolved]]
51-
`CreateTable` can never be [resolved](../expressions/Expression.md#resolved) and is replaced (_resolved_) with a logical command at analysis phase in the following rules:
52-
53-
* (for non-hive data source tables) [DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md) posthoc logical resolution rule to a <<CreateDataSourceTableCommand.md#, CreateDataSourceTableCommand>> or a <<CreateDataSourceTableAsSelectCommand.md#, CreateDataSourceTableAsSelectCommand>> logical command (when the <<query, query>> was defined or not, respectively)
54-
55-
* (for hive tables) hive/HiveAnalysis.md[HiveAnalysis] post-hoc logical resolution rule to a `CreateTableCommand` or a [CreateHiveTableAsSelectCommand](../hive/CreateHiveTableAsSelectCommand.md) logical command (when <<query, query>> was defined or not, respectively)
56-
57-
=== [[creating-instance]] Creating CreateTable Instance
58-
59-
`CreateTable` takes the following to be created:
43+
`resolved` is part of the [LogicalPlan](LogicalPlan.md#resolved) abstraction.
6044

61-
* [[tableDesc]] [Table metadata](../CatalogTable.md)
62-
* [[mode]] [SaveMode](../DataFrameWriter.md#SaveMode)
63-
* [[query]] Optional AS query ([Logical query plan](../logical-operators/LogicalPlan.md))
64-
-->
45+
`resolved` is always `false`.

0 commit comments

Comments
 (0)