From 8249fc5c47516bc12ea855b12e415bfa462c05ec Mon Sep 17 00:00:00 2001 From: Kent Yao Date: Wed, 23 Dec 2020 11:12:56 +0800 Subject: [PATCH] [SPARK-33877][SQL] SQL reference documents for INSERT w/ a column list --- docs/sql-ref-syntax-dml-insert-into.md | 10 ++++------ ...l-ref-syntax-dml-insert-overwrite-table.md | 20 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/docs/sql-ref-syntax-dml-insert-into.md b/docs/sql-ref-syntax-dml-insert-into.md index 4396eab1c5430..96a95b1a629e9 100644 --- a/docs/sql-ref-syntax-dml-insert-into.md +++ b/docs/sql-ref-syntax-dml-insert-into.md @@ -49,9 +49,7 @@ INSERT INTO [ TABLE ] table_identifier [ partition_spec ] [ ( column_list ) ] An optional parameter that specifies a comma-separated list of columns belonging to the `table_identifier` table. - **Note** - - The current behaviour has some limitations: + **Note:**The current behaviour has some limitations: - All specified columns should exist in the table and not be duplicated from each other. It includes all columns except the static partition columns. - The size of the column list should be exactly the size of the data from `VALUES` clause or query. - The order of the column list is alterable and determines how the data from `VALUES` clause or query to be inserted by position. @@ -219,7 +217,7 @@ SELECT * FROM students WHERE name = 'Kent Yao'; +---------+----------------------+----------+ | name| address|student_id| +---------+----------------------+----------+ -|Kent Yao |Hangzhou, China | 11215016| +|Kent Yao | Hangzhou, China| 11215016| +---------+----------------------+----------+ ``` @@ -229,11 +227,11 @@ SELECT * FROM students WHERE name = 'Kent Yao'; INSERT INTO students PARTITION (student_id = 11215017) (address, name) VALUES ('Hangzhou, China', 'Kent Yao Jr.'); -SELECT * FROM students WHERE student_id = '11215017'; +SELECT * FROM students WHERE student_id = 11215017; +------------+----------------------+----------+ | name| address|student_id| +------------+----------------------+----------+ -|Kent Yao Jr.|Hangzhou, China | 11215017| +|Kent Yao Jr.| Hangzhou, China| 11215017| +------------+----------------------+----------+ ``` diff --git a/docs/sql-ref-syntax-dml-insert-overwrite-table.md b/docs/sql-ref-syntax-dml-insert-overwrite-table.md index 97e51b806669e..f2413fb72464f 100644 --- a/docs/sql-ref-syntax-dml-insert-overwrite-table.md +++ b/docs/sql-ref-syntax-dml-insert-overwrite-table.md @@ -47,14 +47,14 @@ INSERT OVERWRITE [ TABLE ] table_identifier [ partition_spec [ IF NOT EXISTS ] ] * **column_list** - An optional parameter that specifies a comma-separated list of columns belonging to the `table_identifier` table. + An optional parameter that specifies a comma-separated list of columns belonging to the `table_identifier` table. - **Note** + **Note** - The current behaviour has some limitations: - - All specified columns should exist in the table and not be duplicated from each other. It includes all columns except the static partition columns. - - The size of the column list should be exactly the size of the data from `VALUES` clause or query. - - The order of the column list is alterable and determines how the data from `VALUES` clause or query to be inserted by position. + The current behaviour has some limitations: + - All specified columns should exist in the table and not be duplicated from each other. It includes all columns except the static partition columns. + - The size of the column list should be exactly the size of the data from `VALUES` clause or query. + - The order of the column list is alterable and determines how the data from `VALUES` clause or query to be inserted by position. * **VALUES ( { value `|` NULL } [ , ... ] ) [ , ( ... ) ]** @@ -190,21 +190,21 @@ SELECT * FROM students WHERE name = 'Kent Yao'; +---------+----------------------+----------+ | name| address|student_id| +---------+----------------------+----------+ -|Kent Yao |Hangzhou, China | 11215016| +|Kent Yao | Hangzhou, China| 11215016| +---------+----------------------+----------+ ``` #### Insert with both a partition spec and a column list ```sql -INSERT OVERWRITE students PARTITION (student_id = 11215017) (address, name) VALUES +INSERT OVERWRITE students PARTITION (student_id = 11215016) (address, name) VALUES ('Hangzhou, China', 'Kent Yao Jr.'); -SELECT * FROM students WHERE student_id = '11215017'; +SELECT * FROM students WHERE student_id = 11215016; +------------+----------------------+----------+ | name| address|student_id| +------------+----------------------+----------+ -|Kent Yao Jr.|Hangzhou, China | 11215017| +|Kent Yao Jr.| Hangzhou, China| 11215016| +------------+----------------------+----------+ ```