Snowflake 中的流:捕获一行中的所有更改,而不仅仅是当前的净更改?
Streams in Snowflake: Capturing all changes to a row, not only net changes until present?
(代表 Snowflake 用户提交 - 希望找到解决方案以加快解决速度)
我们正在研究使用流来完成缓慢变化的维度。
以下文章很有帮助,但我们正在寻找一种方法来构建更详尽的变更捕获?
- https://www.snowflake.com/blog/building-a-type-2-slowly-changing-dimension-in-snowflake-using-streams-and-tasks-part-1/
- https://community.snowflake.com/s/article/Building-a-Type-2-Slowly-Changing-Dimension-in-Snowflake-Using-Streams-and-Tasks-Part-2
考虑这个例子:
1) Insert into MyTable row 1
2) Select * from StreamOfMyTable
<====== Returns 插入,如预期的那样
3) Update MyTable where Row = 1
4) Select * from StreamOfMyTable
仅显示 Net Change,一个 insert ,包含步骤 3 中的更新值。如果我们要在此处使用流,我们无法知道第 1 行曾经具有在步骤 1 中给定的值。
在第 4 步中,我们希望在流中看到第 1 步中的原始插入和第 3 步中的更新。这样我们就可以构建更完整的 SCD 类型 2,而不仅仅是我们使用 DML 操作使用流的时间。
我们确实看到了如何通过时间旅行,使用 "before (statement => 'my query guid')" 短语创建一个新的 StreamOfMyTableAtSpecificPointInTime。但这似乎很极端,必须对我们所有的表进行编码。 是否有更原生的方式来捕获所有更改?
注意:
被问到"Why do you need the previous values of the row to build an SCD type 2? You should just be able to merge into your final dimension based on some ID and update the previous record to "close it" 对吧?之前的值应该在你的final dimension中?"
我的回复:"The stream does not contain multiple changes to the same row, only the net change to it. Try updating a row more than once before processing the stream. Notice how only the final value is in the stream."
对如何进行有什么建议吗?
简而言之,您描述的行为是 Streams 在 Snowflake 中的工作方式。他们不被考虑和审计日志 table.
您可以 运行 任务并以较小的间隔处理流,但是如果源上有多个更改 table 只有 DML 操作的网络在流中可用时已处理。
对于给定的唯一记录,您希望在源 table 中进行更新的速度有多快?
(代表 Snowflake 用户提交 - 希望找到解决方案以加快解决速度)
我们正在研究使用流来完成缓慢变化的维度。
以下文章很有帮助,但我们正在寻找一种方法来构建更详尽的变更捕获?
- https://www.snowflake.com/blog/building-a-type-2-slowly-changing-dimension-in-snowflake-using-streams-and-tasks-part-1/
- https://community.snowflake.com/s/article/Building-a-Type-2-Slowly-Changing-Dimension-in-Snowflake-Using-Streams-and-Tasks-Part-2
考虑这个例子:
1) Insert into MyTable row 1
2) Select * from StreamOfMyTable
<====== Returns 插入,如预期的那样
3) Update MyTable where Row = 1
4) Select * from StreamOfMyTable
仅显示 Net Change,一个 insert ,包含步骤 3 中的更新值。如果我们要在此处使用流,我们无法知道第 1 行曾经具有在步骤 1 中给定的值。
在第 4 步中,我们希望在流中看到第 1 步中的原始插入和第 3 步中的更新。这样我们就可以构建更完整的 SCD 类型 2,而不仅仅是我们使用 DML 操作使用流的时间。
我们确实看到了如何通过时间旅行,使用 "before (statement => 'my query guid')" 短语创建一个新的 StreamOfMyTableAtSpecificPointInTime。但这似乎很极端,必须对我们所有的表进行编码。 是否有更原生的方式来捕获所有更改?
注意:
被问到"Why do you need the previous values of the row to build an SCD type 2? You should just be able to merge into your final dimension based on some ID and update the previous record to "close it" 对吧?之前的值应该在你的final dimension中?"
我的回复:"The stream does not contain multiple changes to the same row, only the net change to it. Try updating a row more than once before processing the stream. Notice how only the final value is in the stream."
对如何进行有什么建议吗?
简而言之,您描述的行为是 Streams 在 Snowflake 中的工作方式。他们不被考虑和审计日志 table.
您可以 运行 任务并以较小的间隔处理流,但是如果源上有多个更改 table 只有 DML 操作的网络在流中可用时已处理。
对于给定的唯一记录,您希望在源 table 中进行更新的速度有多快?