Skip to content

Commit

Permalink
[FLINK-21542][docs][table] Add documentation for supporting INSERT IN…
Browse files Browse the repository at this point in the history
…TO specific columns

This closes apache#15070
  • Loading branch information
docete committed Mar 5, 2021
1 parent b743f2a commit 01794fe
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/content/docs/dev/table/sql/insert.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,13 @@ Query Results can be inserted into tables by using the insert clause.

```sql

INSERT { INTO | OVERWRITE } [catalog_name.][db_name.]table_name [PARTITION part_spec] select_statement
INSERT { INTO | OVERWRITE } [catalog_name.][db_name.]table_name [PARTITION part_spec] [column_list] select_statement

part_spec:
(part_col_name1=val1 [, part_col_name2=val2, ...])

column_list:
(col_name1 [, column_name2, ...])
```

**OVERWRITE**
Expand All @@ -206,6 +208,11 @@ part_spec:

`PARTITION` clause should contain static partition columns of this inserting.

**COLUMN LIST**

Given a table T(a INT, b INT, c INT), Flink supports INSERT INTO T(c, b) SELECT x, y FROM S. The expectation is
that 'x' is written to column 'c' and 'y' is written to column 'b' and 'a' is set to NULL (assuming column 'a' is nullable).

### Examples

```sql
Expand All @@ -231,6 +238,11 @@ INSERT OVERWRITE country_page_view PARTITION (date='2019-8-30', country='China')
-- country is dynamic partition whose value is dynamic determined by each row.
INSERT OVERWRITE country_page_view PARTITION (date='2019-8-30')
SELECT user, cnt, country FROM page_view_source;

-- Appends rows into the static partition (date='2019-8-30', country='China')
-- the column cnt is set to NULL
INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China') (user)
SELECT user FROM page_view_source;
```


Expand Down

0 comments on commit 01794fe

Please sign in to comment.