You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/logical-operators/CreateTable.md
+17-36Lines changed: 17 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,14 @@ title: CreateTable
6
6
7
7
`CreateTable` is a [LogicalPlan](LogicalPlan.md).
8
8
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
+
9
17
## Creating Instance
10
18
11
19
`CreateTable` takes the following to be created:
@@ -17,48 +25,21 @@ title: CreateTable
17
25
While being created, `CreateTable` asserts the following:
18
26
19
27
* 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`
21
29
22
30
`CreateTable` is created when:
23
31
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))
25
33
*[ResolveSessionCatalog](../logical-analysis-rules/ResolveSessionCatalog.md) logical resolution rule is executed (to [constructV1TableCmd](../logical-analysis-rules/ResolveSessionCatalog.md#constructV1TableCmd))
26
34
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 }
37
36
38
-
`CreateTable` requires that the [table provider](../CatalogTable.md#provider) of the [CatalogTable](#tableDesc) is defined or throws an `AssertionError`:
37
+
??? note "LogicalPlan"
39
38
40
-
```text
41
-
assertion failed: The table to be created must have a provider.
42
-
```
39
+
```scala
40
+
resolved: Boolean
41
+
```
43
42
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)
0 commit comments