首页 > 解决方案 > 结构化流上作业管道的 delta Lake 最佳分区策略

问题描述

在我的场景中,我有 2 个结构化流作业,一个写入 Delta Lake 表,第二个从 Delta Lake 表读取的作业处理它并写入另一个表。

对于结构化流(只需要选择在最后一个流批处理之后插入的新记录),我应该创建的分区的最佳选择是什么。如果我在表中使用 CreatedDateTime 列,从该表读取的下一个作业是否将使用该分区。由于我只是使用 readstream(),我不确定它将使用哪个分区。

标签: databricksspark-structured-streamingazure-databricks

解决方案


It depends on the data itself on what column you should use for partitioning. If your data is distributed proportionally along the dates, then yes CreatedDateTime would work (what does the histogram look like? Do you not have any "peak" times where a lot of data comes in?). However, if it is not, your primary key might be a safer bet.


推荐阅读