在第 1 行第 1 列遇到“"MERGE""MERGE "”。预期:<EOF>
Encountered " "MERGE" "MERGE "" at line 1, column 1. Was expecting: <EOF>
我们必须在 BigQuery 中使用 Legacy SQL。但是,Merge 在 Legacy SQL 中不起作用。我们如何在 Legacy SQL?
中编写以下查询
MERGE [ABC:xyz.tmp_cards] AS target_tbl
USING [ABC:xyz.tmp_cards_1533188902] AS source_tbl
ON target_tbl.id = source_tbl.id
WHEN MATCHED AND target_tbl.id = source_tbl.id THEN
UPDATE SET target_tbl.id = source_tbl.id,
target_tbl.user_id = source_tbl.user_id,
target_tbl.expiration_date = source_tbl.expiration_date,
target_tbl.created_at = source_tbl.created_at,
target_tbl.updated_at = source_tbl.updated_at
WHEN NOT MATCHED THEN
INSERT (id, user_id, expiration_date, created_at, updated_at)
VALUES (source_tbl.id, source_tbl.user_id, source_tbl.expiration_date, source_tbl.created_at, source_tbl.updated_at)
支持 DML MERGE 语句appeared in Beta just this year for standard SQL. It's not possible to do it in Legacy SQL and this is why Standard SQL is the preferred SQL dialect 以查询存储在 BigQuery 中的数据。因为新功能是针对 BigQuery 的最后一个 DML 而不是旧的。
我们必须在 BigQuery 中使用 Legacy SQL。但是,Merge 在 Legacy SQL 中不起作用。我们如何在 Legacy SQL?
中编写以下查询MERGE [ABC:xyz.tmp_cards] AS target_tbl
USING [ABC:xyz.tmp_cards_1533188902] AS source_tbl
ON target_tbl.id = source_tbl.id
WHEN MATCHED AND target_tbl.id = source_tbl.id THEN
UPDATE SET target_tbl.id = source_tbl.id,
target_tbl.user_id = source_tbl.user_id,
target_tbl.expiration_date = source_tbl.expiration_date,
target_tbl.created_at = source_tbl.created_at,
target_tbl.updated_at = source_tbl.updated_at
WHEN NOT MATCHED THEN
INSERT (id, user_id, expiration_date, created_at, updated_at)
VALUES (source_tbl.id, source_tbl.user_id, source_tbl.expiration_date, source_tbl.created_at, source_tbl.updated_at)
支持 DML MERGE 语句appeared in Beta just this year for standard SQL. It's not possible to do it in Legacy SQL and this is why Standard SQL is the preferred SQL dialect 以查询存储在 BigQuery 中的数据。因为新功能是针对 BigQuery 的最后一个 DML 而不是旧的。