lava-oushudb-dt-sql-parser/test/parser/impala/syntax/fixtures/upsert.sql
霜序 e203f1a48a
feat: support impala (#184)
* feat(impala): add impala sqlLexer

* feat(impala): add impala grammar

* feat(impala): add alter table sql

* feat(impala): update alter table sql

* feat(impala): add alter db sql

* feat(impala): add alter view sql

* feat(impala): add compute stats/comment statement and update partition_desc for alter table

* feat(impala): add drop statement sql

* feat(impala): add revoke and grant sql

* feat(impala): add create db/function/role/view sql

* feat(impala): add describe/explain/invalidata_metadata/load_data sql

* feat(impala): add refresh/set/shutdown sql

* feat(impala): add truncate_table/use/values sql

* fix(impala): update shutdown and invaliddate_metadata

* feat(impala): add show/update/upsert sql

* feat(impala): add create/insert sql

* feat(impala): add select and delete sql

* feat(impala): add impala tokens and fix todo

* feat(impala): update impalaparser and some test unit

* feat(impala): add syntax suggestion

* feat(impala): add syntax suggestion

* feat(impala): update test unit

* feat(impala): remove reference

* fix(impala): add statement for sqlname and collect tableName

* fix(impala): fix syntax suggestion unit test

* fix(impala): update syntax suggestion and collect column

* feat(impala): add collect column create
2023-11-28 21:11:07 +08:00

89 lines
1.4 KiB
SQL

/* UPSERT [hint_clause] INTO [TABLE] [db_name.]table_name
[(column_list)]
{
[hint_clause] select_statement
| VALUES (value [, value ...]) [, (value [, value ...]) ...]
} */
UPSERT INTO my_table
SELECT
id,
'new_value1',
'new_value2'
FROM
other_table
WHERE
condition;
UPSERT -- +NOSHUFFLE -- +CLUSTERED
INTO my_table
/* +NOSHUFFLE */
SELECT
id,
'new_value1',
'new_value2'
FROM
other_table
WHERE
condition;
UPSERT INTO my_table -- +SHUFFLE
SELECT
id,
'new_value1',
'new_value2'
FROM
other_table
WHERE
condition;
UPSERT INTO my_table (id, col1, col2)
SELECT
id,
'new_value1',
'new_value2'
FROM
other_table
WHERE
condition;
UPSERT INTO TABLE my_db.my_table (id, col1, col2)
SELECT
id,
'new_value1',
'new_value2'
FROM
other_table
WHERE
condition;
UPSERT INTO my_table (id, col1, col2)
VALUES
(1, 'new_value1', 'new_value2'),
(2, 'new_value3', 'new_value4');
UPSERT -- +NOSHUFFLE -- +CLUSTERED
INTO my_db.my_table
VALUES
(1, 'new_value1', 'new_value2'),
(2, 'new_value3', 'new_value4');
-- example
UPSERT INTO kudu_table (pk, c1, c2, c3)
VALUES
(0, 'hello', 50, true),
(1, 'world', -1, false);
UPSERT INTO production_table
SELECT
*
FROM
staging_table;
UPSERT INTO production_table
SELECT
*
FROM
staging_table
WHERE
c1 IS NOT NULL
AND c2 > 0;