我已經多次在 DWH 上批量實施緩慢變化的維度,從而可以處理給定業務密鑰的一組大于 1 的更改。沒有汗水。
使用以下:
- Spark 非結構化流程式
- ETL 工具
- PL/SQL
但是,據我所知,使用結構化流式傳輸是不可能的,因為它具有多步驟性質以及 Spark 結構化流式傳輸存在的限制。
或者這可能嗎?如果有,請指教是否有方法?
uj5u.com熱心網友回復:
是的,這是可能的,但您需要一些代碼來實作它。從您的更新資料框中,您需要創建一個聯合:
- 更新自己,這將有一個完整的合并鍵 - 他們將匹配你將設定
current = false和end_date = date_of_new_record - 與目標表進行內部連接的結果,但將合并鍵設定為 NULL,因此它們將不匹配 & 將作為新行插入
current = true和end_date = null
代碼來自官方檔案(和筆記本):
-- These rows will either UPDATE the current addresses of existing
-- customers or INSERT the new addresses of new customers
SELECT updates.customerId as mergeKey, updates.* FROM updates
UNION ALL
-- These rows will INSERT new addresses of existing customers
-- Setting the mergeKey to NULL forces these rows
— to NOT MATCH and be INSERTed.
SELECT NULL as mergeKey, updates.*
FROM updates JOIN customers
ON updates.customerid = customers.customerid
WHERE customers.current = true
AND updates.address <> customers.address
然后這個生成的資料框用于從 .foreachBatch
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/416375.html
標籤:
