MERGE INTO prod.db.target t -- a target table
USING (SELECT ...) s -- the source updates
ON t.id = s.id -- condition to find updates for target rows
WHEN ... -- updates
WHEN MATCHED AND s.op = 'delete' THEN DELETE
WHEN MATCHED AND t.count IS NULL AND s.op = 'increment' THEN UPDATE SET t.count = 0
WHEN MATCHED AND s.op = 'increment' THEN UPDATE SET t.count = t.count + 1
WHEN NOT MATCHED THEN INSERT *
WHEN NOT MATCHED AND s.event_time > still_valid_threshold THEN INSERT (id, count) VALUES (s.id, 1)
insert overwrite如果spark.sql.sources.partitionOverwriteMode=static全量覆盖,如果spark.sql.sources.partitionOverwriteMode=dynamic新增的分区覆盖;
DELETE FROM prod.db.table
WHERE ts >= '2020-05-01 00:00:00' and ts < '2020-06-01 00:00:00'
DELETE FROM prod.db.all_events
WHERE session_time < (SELECT min(session_time) FROM prod.db.good_events)
DELETE FROM prod.
spark写iceberg
最新推荐文章于 2024-07-13 16:20:50 发布
本文介绍如何利用Apache Spark进行Iceberg数据湖的读写操作,内容涵盖Spark SQL的集成,数据写入与查询的步骤,以及在大数据场景中的应用。
摘要由CSDN通过智能技术生成