1
我已經如下兩種情況:火花SQL:催化劑是不希望的掃描列
scala> val dfA = sqlContext.read.parquet("/home/mohit/ruleA")
dfA: org.apache.spark.sql.DataFrame = [aid: int, aVal: string]
scala> val dfB = sqlContext.read.parquet("/home/mohit/ruleB")
dfB: org.apache.spark.sql.DataFrame = [bid: int, bVal: string]
scala> dfA.registerTempTable("A")
scala> dfB.registerTempTable("B")
1。左加入與過濾器在WHERE
sqlContext.sql("select A.aid, B.bid from A left join B on A.aid=B.bid where B.bid<2").explain
== Physical Plan ==
Project [aid#15,bid#17]
+- Filter (bid#17 < 2)
+- BroadcastHashOuterJoin [aid#15], [bid#17], LeftOuter, None
:- Scan ParquetRelation[aid#15,aVal#16] InputPaths: file:/home/mohit/ruleA
+- Scan ParquetRelation[bid#17,bVal#18] InputPaths: file:/home/mohit/ruleB
2.左聯接在過濾器ON
sqlContext.sql("select A.aid, B.bid from A left join B on A.aid=B.bid and B.bid<2").explain
== Physical Plan ==
Project [aid#15,bid#17]
+- BroadcastHashOuterJoin [aid#15], [bid#17], LeftOuter, None
:- Scan ParquetRelation[aid#15] InputPaths: file:/home/mohit/ruleA
+- Filter (bid#17 < 2)
+- Scan ParquetRelation[bid#17] InputPaths: file:/home/mohit/ruleB, PushedFilters: [LessThan(bid,2)]
問題
無論哪種情況,Catalyst
都有來自表B的信息,只需要B.bid
(出價#17)。爲什麼在WHERE
的情況下需要全表掃描。表B的projection
列是隱含的和確定性的。
注意:這是一個來自生產問題的淡化示例。 Spark版本 - 1.6.2。
它看起來像一個錯誤 - 如果沒有人會在這裏幫你,那麼在Spark開發人員小組上發佈將是一個好主意 –