![](/img/trans.png)
[英]How reliable is spark stream join with static databricks delta table
[英]How to get a snapshot of a streaming delta table as a static table in Databricks?
假设我在 Databricks 中有一个流式增量表。 有什么方法可以将流式表的快照作为 static 表?
原因是我需要通过以下方式将此流表与 static 表连接起来:
output = output.join(country_information, ["Country"], "left")
“Output”是一个 static 表,“country_information”是流表。
但是,我收到错误:
Append mode error: LeftOuter join with a streaming DataFrame/Dataset on the right and a static DataFrame/Dataset on the left is not supported;
另外,我无法将上面的代码更改为:
country_information = country_information.join(output, ["Country"], "left")
因为逻辑不通。
如果您有任何想法,请告诉我。 我为我的任务使用 Python,而不是 SQL。
是的,你可以试试这个方法
# Create the snapshot with timestamp
snapshot_time = "2022-10-01 00:00:00"
spark.sql(f"CREATE TABLE snapshot_table_at_time AS SELECT * FROM streaming_table VERSION AS OF '{snapshot_time}'")
然后,您可以将其保存为数据框
snapshot_df = spark.read.format("delta").option("timestampAsOf", snapshot_time).load("streaming_table").toDF()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.