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
`CreateDataSourceTableCommand` is a RunnableCommand.md[logical command]that <<run, creates a new table>> (in a [SessionCatalog](../SessionCatalog.md)).
7
+
`CreateDataSourceTableCommand` is a [LeafRunnableCommand](LeafRunnableCommand.md)that represents a [CreateTable](CreateTable.md) logical operator (with [DataSource Tables](../connectors/DDLUtils.md#isDatasourceTable)) at execution.
8
8
9
-
`CreateDataSourceTableCommand`is created when [DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md) posthoc logical resolution rule resolves a CreateTable.md[CreateTable] logical operator for a non-Hive table provider with no query.
9
+
`CreateDataSourceTableCommand`uses the [SessionCatalog](../SessionState.md#catalog) to [create a table](../SessionCatalog.md#createTable) when [executed](#run).
10
10
11
11
## Creating Instance
12
12
13
13
`CreateDataSourceTableCommand` takes the following to be created:
*[DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md) posthoc logical resolution rule is executed (to resolve [CreateTable](CreateTable.md) logical operators with [DataSource Tables](../connectors/DDLUtils.md#isDatasourceTable))
24
21
25
-
NOTE: `run` is part of <<RunnableCommand.md#run, RunnableCommand Contract>> to execute (run) a logical command.
22
+
## Executing Command { #run }
26
23
27
-
`run` requests a session-scoped `SessionCatalog` to [create a table](../SessionCatalog.md#createTable).
24
+
??? note "RunnableCommand"
28
25
29
-
NOTE: `run` uses the input `SparkSession` to SparkSession.md#sessionState[access SessionState] that in turn is used to SessionState.md#catalog[access the current SessionCatalog].
26
+
```scala
27
+
run(
28
+
sparkSession: SparkSession): Seq[Row]
29
+
```
30
30
31
-
Internally, `run`[creates a BaseRelation](../DataSource.md#resolveRelation) to access the table's schema.
31
+
`run` is part of the [RunnableCommand](RunnableCommand.md#run) abstraction.
32
32
33
-
CAUTION: FIXME
33
+
`run` requests the [SessionCatalog](../SessionState.md#catalog) to [tableExists](../SessionCatalog.md#tableExists). With `ignoreIfExists` flag enabled, `run` exits. Otherwise, `run` reports a `TableAlreadyExistsException`.
34
34
35
-
NOTE: `run` accepts tables only (not views) with the provider defined.
35
+
`run` uses the [locationUri](../CatalogStorageFormat.md#locationUri) as the `path` option.
36
+
37
+
`run` uses the [current database](../SessionCatalog.md#getCurrentDatabase) (of the [SessionCatalog](../SessionState.md#catalog)) unless defined.
38
+
39
+
`run` sets the [tracksPartitionsInCatalog](../CatalogTable.md#tracksPartitionsInCatalog) to the value of [spark.sql.hive.manageFilesourcePartitions](../configuration-properties.md#spark.sql.hive.manageFilesourcePartitions) configuration property.
40
+
41
+
`run` creates a [DataSource](../DataSource.md) to [resolveRelation](../DataSource.md#resolveRelation).
42
+
43
+
In the end, `run` requests the [SessionCatalog](../SessionState.md#catalog) to [create a table](../SessionCatalog.md#createTable).
44
+
45
+
??? note "AssertionError"
46
+
47
+
`run` expects the following (or reports an `AssertionError`):
48
+
49
+
* The [tableType](../CatalogTable.md#tableType) of the [CatalogTable](#table) is not `view`
50
+
* The [provider](../CatalogTable.md#provider) of the [CatalogTable](#table) is defined
0 commit comments