![](/img/trans.png)
[英]Apache Spark - 'LeftAnti' join Ambiguous column error
[英]Spark Java except method vs. leftanti join returning inconsistent results, possible bug?
Spark數據框Java API中似乎遇到了一個錯誤。 我正在使用spark 2.3.1。 我已經花了好幾天的時間撓頭,我不知道為什么使用除vs. leftanti過濾掉不需要的數據的兩種方法之間的結果會有所不同的原因。
看來,except函數實際上是一個與眾不同的except! 除之外調用的數據幀將刪除所有重復項!
只是想提供此信息,以防其他人遇到同樣的問題! 運行except函數會在結果數據框中生成唯一數據。 要保留原始數據,請確保使用leftanti!
似乎從2.3.0開始 , .except()
充當EXCEPT DISTINCT
操作。 前面提到EXCEPT
文檔是不正確的,因為該行為始終是EXCEPT DISTINCT
如果您比較leftanti
計划
== Physical Plan ==
*BroadcastHashJoin [value#1], [value#4], LeftAnti, BuildRight
:- LocalTableScan [value#1]
+- BroadcastExchange HashedRelationBroadcastMode(List(input[0, string, true]))
+- LocalTableScan [value#4]
和except()
:
== Physical Plan ==
*HashAggregate(keys=[value#1], functions=[])
+- Exchange hashpartitioning(value#1, 200)
+- *HashAggregate(keys=[value#1], functions=[])
+- *BroadcastHashJoin [coalesce(value#1, )], [coalesce(value#4, )], LeftAnti, BuildRight, (value#1 <=> value#4)
:- LocalTableScan [value#1]
+- BroadcastExchange HashedRelationBroadcastMode(List(coalesce(input[0, string, true], )))
+- LocalTableScan [value#4]
您可以看到還有其他的HashAggregate
步驟可以刪除重復項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.