Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions docs/sql-ref-syntax-dml-insert-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ The `INSERT` statement inserts new rows into a table or overwrites the existing
### Syntax

```sql
INSERT [ WITH SCHEMA EVOLUTION ] [ INTO | OVERWRITE ] [ TABLE ] table_identifier [ partition_spec ] [ ( column_list ) | [BY NAME] ]
INSERT [ WITH SCHEMA EVOLUTION ] [ INTO | OVERWRITE ] [ TABLE ] table_identifier
[ WITH ( option_key = option_value [ , ... ] ) ] [ partition_spec ]
[ ( column_list ) | [BY NAME] ]
{ VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query }

INSERT [ WITH SCHEMA EVOLUTION ] INTO [ TABLE ] table_identifier [ BY NAME ] REPLACE WHERE boolean_expression query
INSERT [ WITH SCHEMA EVOLUTION ] INTO [ TABLE ] table_identifier
[ WITH ( option_key = option_value [ , ... ] ) ] [ BY NAME ]
REPLACE WHERE boolean_expression query
```

### Parameters
Expand All @@ -46,6 +50,11 @@ INSERT [ WITH SCHEMA EVOLUTION ] INTO [ TABLE ] table_identifier [ BY NAME ] REP

**Syntax:** `[ database_name. ] table_name`

* **WITH ( option_key = option_value [ , ... ] )**

Specifies dynamic table options for this `INSERT` operation. These options are passed to the
data source connector when writing to the table. The supported options depend on the connector.

* **partition_spec**

An optional parameter that specifies a comma-separated list of key and value pairs
Expand Down Expand Up @@ -88,6 +97,14 @@ INSERT [ WITH SCHEMA EVOLUTION ] INTO [ TABLE ] table_identifier [ BY NAME ] REP

#### Insert Into

##### Insert Using Dynamic Table Options

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we put it towards the end ? Its more a speciality so I feel shouldn't be the first one.


```sql
-- Option names and values are specific to the table's data source connector.
INSERT INTO students WITH (`write.split-size` = 10)
VALUES ('Amy Smith', '123 Park Ave, San Jose', 111111);
```

##### Single Row Insert Using a VALUES Clause

```sql
Expand Down
22 changes: 21 additions & 1 deletion docs/sql-ref-syntax-dml-merge-into.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ apply. All of these row-level changes are performed as a single atomic operation

```sql
MERGE [ WITH SCHEMA EVOLUTION ] INTO target_table [ [ AS ] target_alias ]
USING { source_table | ( source_query ) } [ [ AS ] source_alias ]
[ WITH ( target_option_key = target_option_value [ , ... ] ) ]
USING { source_table [ WITH ( source_option_key = source_option_value [ , ... ] ) ] |
( source_query ) } [ [ AS ] source_alias ]
ON merge_condition
[ WHEN MATCHED [ AND matched_condition ] THEN matched_action ] [ ... ]
[ WHEN NOT MATCHED [ BY TARGET ] [ AND not_matched_condition ] THEN not_matched_action ] [ ... ]
Expand Down Expand Up @@ -69,6 +71,13 @@ not_matched_by_source_action
The source of the merge, specified either as a table or as a parenthesized query. An optional
alias may be provided with or without the `AS` keyword.

* **WITH ( option_key = option_value [ , ... ] )**

Specifies dynamic table options for this `MERGE` operation. Options following the target table
are passed to the data source connector for the write operation. Options following the source
table are passed to the connector when reading the source. The supported options depend on the
connector.

* **merge_condition**

A boolean expression, introduced by the `ON` keyword, that determines how rows from the source
Expand Down Expand Up @@ -149,6 +158,17 @@ SELECT * FROM source;
+--+------+-----+
```

#### Merge Using Dynamic Table Options

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


```sql
-- Option names and values are specific to each table's data source connector.
MERGE INTO target t WITH (`write.split-size` = 10)
USING source WITH (`split-size` = 5) s
ON t.pk = s.pk
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *;
```

#### Update Matched Rows and Insert New Rows

```sql
Expand Down
21 changes: 21 additions & 0 deletions docs/sql-ref-syntax-qry-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { [ [ named_expression | regex_column_
[ QUALIFY boolean_expression ]
```

A table relation in `from_item` can include dynamic table options:

```sql
table_identifier [ WITH ( option_key = option_value [ , ... ] ) ] [ [ AS ] table_alias ]
```

### Parameters

* **with_query**
Expand Down Expand Up @@ -97,6 +103,11 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { [ [ named_expression | regex_column_
* [UNNEST relation](sql-ref-syntax-qry-select-unnest.html)
* [ [LATERAL](sql-ref-syntax-qry-select-lateral-subquery.html) ] ( Subquery )
* [File](sql-ref-syntax-qry-select-file.html)

* **WITH ( option_key = option_value [ , ... ] )**

Specifies dynamic table options for a table relation. These options are passed to the data
source connector when reading the table. The supported options depend on the connector.

* **PIVOT**

Expand Down Expand Up @@ -191,6 +202,16 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { [ [ named_expression | regex_column_

Specifies a hive-style transform query specification to transform the input by forking and running user-specified command or script.

### Examples

#### Select Using Dynamic Table Options

```sql
-- Option names and values are specific to the table's
-- data source connector.
SELECT * FROM students WITH (`split-size` = 5);
```

### Related Statements

* [WHERE Clause](sql-ref-syntax-qry-select-where.html)
Expand Down