Skip to content

Commit

Permalink
[SPARK-33877][SQL] SQL reference documents for INSERT w/ a column list
Browse files Browse the repository at this point in the history
  • Loading branch information
yaooqinn committed Dec 23, 2020
1 parent 5d22049 commit 8249fc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
10 changes: 4 additions & 6 deletions docs/sql-ref-syntax-dml-insert-into.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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|
+---------+----------------------+----------+
```

Expand All @@ -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|
+------------+----------------------+----------+
```

Expand Down
20 changes: 10 additions & 10 deletions docs/sql-ref-syntax-dml-insert-overwrite-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 } [ , ... ] ) [ , ( ... ) ]**

Expand Down Expand Up @@ -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|
+------------+----------------------+----------+
```

Expand Down

0 comments on commit 8249fc5

Please sign in to comment.