【发布时间】:2021-08-04 02:27:33
【问题描述】:
我正在尝试将数据合并到我数据库中的现有表中。我要合并的数据不在现有表中,所以我想在我的 SQL 查询中将它作为表文字提供给我的数据库。以下是我目前得到的代码 - 它不断出错并显示一条消息:
SQL compilation error: error line 8 at position 39 invalid identifier 'VALS.COL2'
merge into existing_table
using
(select col1, col2, parse_json(col3) from
values
('2021-08-03 17:38:53.977484+00:00', '34o234j3', $${"data":"here's some data","data2":"Here's some more data"}$$),
('2021-08-02 08:38:55', '1934802h32', $${"data":"here's some dataX","data2":"Here's some more dataY"}$$)
as vals(col1, col2, col3))
on existing_table.sales_order_id = vals.col2
when matched then
update set
existing_table.timestamp_utc = vals.colOne, existing_table.JSON = vals.colThree
when not matched then
insert (timestamp_utc, sales_order_id, JSON)
values (vals.colOne, vals.colTwo, vals.colThree);
请注意,我正在使用 Snowflake 应用程序来保存数据 - Snowflake 应用程序允许使用 parse_json() 函数。
【问题讨论】:
标签: python merge snowflake-cloud-data-platform