Spark SQL: Catalyst 正在扫描不需要的列

Spark SQL: Catalyst is scanning undesired columns

我有以下两种情况:

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 .Left Join with Filter in 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。左加入过滤器开启

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 都从 table B 那里得到信息,只需要 B.bid (bid#17)。为什么在 WHERE 案例中需要整个 table 扫描。 table B 的 projection 列是隐式和确定性的。

注意:这是来自生产问题的淡化示例。 Spark 版本 - 1.6.2.

我在 JIRA-18642 的 Spark 上提出了这个问题。这是 Spark 1.6 中的一个真正的错误。