我在 Spark 中将一些 DataFrames 连接在一起,但我不断收到以下错误:
PartitioningCollection requires all of its partitionings have the same numPartitions.
这似乎发生在我将两个 DataFrame 连接在一起之后,每个 DataFrame 本身看起来都相当合理,但是在加入它们之后,如果我尝试从连接的 DataFrame 中获取一行,我会收到这个错误。我真的只是想了解为什么会出现此错误或其背后的含义,因为我似乎找不到任何文档。
以下调用导致此异常:
val resultDataframe = dataFrame1
.join(dataFrame2,
$"first_column" === $"second_column").take(2)
但我当然可以打电话
dataFrame1.take(2)
和
dataFrame2.take(2)
我还尝试在加入之前和加入之前使用或重新分区,加入之后DataFrames
重新Dataset.repartition(numPartitions)
分区,但似乎没有任何影响该错误。经过一些粗略的谷歌搜索后,我无法找到其他人得到错误的参考......Dataset.coalesce(numParitions)
dataFrame1
dataFrame2
resultDataFrame