Skip to content

Commit 18285d6

Browse files
AppendData Logical Command and INSERT INTOs
1 parent a76a399 commit 18285d6

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

docs/logical-analysis-rules/ResolveInsertInto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
`ResolveInsertInto` takes no parameters to be created.
1010

11-
`ResolveInsertInto` is created when `Analyzer` is requested for [batches](../Analyzer.md#batches).
11+
`ResolveInsertInto` is created when `Analyzer` is requested for the [batches](../Analyzer.md#batches).
1212

1313
## <span id="apply"> Executing Rule
1414

docs/logical-operators/AppendData.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
`AppendData` is created using [byName](#byName) and [byPosition](#byPosition) operators.
1919

20-
## <span id="isByName"> isByName flag
20+
### <span id="isByName"> isByName flag
2121

22-
`AppendData` is given `isByName` flag when [created](#creating-instance).
22+
`AppendData` is given `isByName` flag when [created](#creating-instance):
23+
24+
* [byName](#byName) with the flag enabled (`true`)
25+
* [byPosition](#byPosition) with the flag disabled (`false`)
2326

2427
`isByName` is part of the [V2WriteCommand](V2WriteCommand.md#isByName) abstraction.
2528

@@ -55,9 +58,9 @@ byPosition(
5558
* [ResolveInsertInto](../logical-analysis-rules/ResolveInsertInto.md) logical resolution rule is executed
5659
* `DataFrameWriter` is requested to [insertInto](../DataFrameWriter.md#insertInto)
5760

58-
## Query Planning
61+
## Execution Planning
5962

60-
`AppendData` is planned to one of the physical operators in [DataSourceV2Strategy](../execution-planning-strategies/DataSourceV2Strategy.md) execution planning strategy:
63+
`AppendData` is planned as one of the physical operators by [DataSourceV2Strategy](../execution-planning-strategies/DataSourceV2Strategy.md) execution planning strategy:
6164

6265
* `AppendDataExecV1`
6366
* `AppendDataExec`
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
# InsertIntoStatement
22

3-
`InsertIntoStatement` is a [ParsedStatement](ParsedStatement.md).
3+
`InsertIntoStatement` is a [UnaryParsedStatement](ParsedStatement.md).
44

55
## Creating Instance
66

77
`InsertIntoStatement` takes the following to be created:
88

9-
* <span id="table"> [Logical Query Plan](LogicalPlan.md)
10-
* <span id="partitionSpec"> Partition Specification
9+
* <span id="table"> Table ([LogicalPlan](LogicalPlan.md))
10+
* <span id="partitionSpec"> Partition Specification (`Map[String, Option[String]]`)
11+
* <span id="userSpecifiedCols"> User-specified column names
1112
* <span id="query"> [Query](LogicalPlan.md)
1213
* <span id="overwrite"> `overwrite` flag
1314
* <span id="ifPartitionNotExists"> `ifPartitionNotExists` flag
1415

1516
`InsertIntoStatement` is created when:
1617

17-
* Catalyst DSL (`DslLogicalPlan`) is used to [insertInto](../catalyst-dsl/index.md#insertInto)
18+
* Catalyst DSL is used to [insertInto](../catalyst-dsl/index.md#insertInto)
1819
* `AstBuilder` is requested to [withInsertInto](../sql/AstBuilder.md#withInsertInto)
1920
* `DataFrameWriter` is requested to [insertInto](../DataFrameWriter.md#insertInto)
21+
22+
## Logical Resolution
23+
24+
`InsertIntoStatement` is resolved to the following logical operators:
25+
26+
* [InsertIntoDataSourceCommand](InsertIntoDataSourceCommand.md) (for `InsertIntoStatement`s over [LogicalRelation](LogicalRelation.md) over [InsertableRelation](../InsertableRelation.md)) by [DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md)
27+
* [InsertIntoHadoopFsRelationCommand](InsertIntoHadoopFsRelationCommand.md) (for `InsertIntoStatement`s over [LogicalRelation](LogicalRelation.md) over [HadoopFsRelation](../InsertableRelation.md)) by [DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md)
28+
29+
## Logical Analysis
30+
31+
`InsertIntoStatement`s with `UnresolvedCatalogRelation`s are resolved by the following logical analysis rules:
32+
33+
* [FindDataSourceTable](../logical-analysis-rules/FindDataSourceTable.md)
34+
* `FallBackFileSourceV2`
35+
* `PreprocessTableInsertion`
36+
* [PreWriteCheck](../logical-analysis-rules/PreWriteCheck.md)

docs/sql/AstBuilder.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,29 @@ ANTLR rule: `singleExpression`
416416

417417
### <span id="visitSingleInsertQuery"> visitSingleInsertQuery
418418

419-
Creates a [LogicalPlan](../logical-operators/LogicalPlan.md) with a [InsertIntoTable](../logical-operators/InsertIntoTable.md)
419+
Calls [withInsertInto](#withInsertInto) (with an `InsertIntoContext`) for the following SQLs:
420420

421421
```sql
422-
INSERT INTO TABLE? tableIdentifier partitionSpec? #insertIntoTable
422+
INSERT OVERWRITE TABLE? multipartIdentifier
423+
(partitionSpec (IF NOT EXISTS)?)?
424+
identifierList?
425+
```
426+
427+
```sql
428+
INSERT INTO TABLE? multipartIdentifier
429+
partitionSpec?
430+
(IF NOT EXISTS)?
431+
identifierList?
432+
```
423433

424-
INSERT OVERWRITE TABLE tableIdentifier (partitionSpec (IF NOT EXISTS)?)? #insertOverwriteTable
434+
```sql
435+
INSERT OVERWRITE LOCAL? DIRECTORY path=STRING rowFormat? createFileFormat?
436+
```
437+
438+
```sql
439+
INSERT OVERWRITE LOCAL? DIRECTORY (path=STRING)?
440+
tableProvider
441+
(OPTIONS options=tablePropertyList)?
425442
```
426443

427444
ANTLR labeled alternative: `#singleInsertQuery`

0 commit comments

Comments
 (0)