Spark筛选器/谓词下推是否无法在ORC文件中正常工作?

时间:2019-09-09 14:54:25

标签: scala apache-spark hive orc

而“ spark.sql.orc.filterPushdown”等于false(默认情况下)。接下来的语句执行了3分钟。

val result = spark.read.schema(schema).orc("s3a://......./*")
result.select("a","b").where(col("a")===1318138224).explain(extended = true)
result.select("a","b").where(col("a")===1318138224).show()

在实际计划中说; PushedFilters:[IsNotNull(a),EqualTo(a,1318138224)]

因此,即使默认情况下通过查看“ PushedFilters”语句禁用了“ filterPushdown”,我也认为spark会以某种方式下推过滤器。

但是在将spark.sql.orc.filterPushdown设置为“ true”后,相同的代码段花费了大约30秒。 奇怪的是,物理计划是相同的

所以我查看了SparkUI的“阶段”部分,输入大小的数量不同。

spark.conf.set(“ spark.sql.orc.filterPushdown”,false) spark.conf.set("spark.sql.orc.filterPushdown", false)

spark.conf.set(“ spark.sql.orc.filterPushdown”,true) spark.conf.set("spark.sql.orc.filterPushdown", true)

因此,即使在Physical的PushedFilters中填充了一些参数(非空),我还是想读取orc文件,这并不意味着Spark实际上会进行下推谓词/过滤器吗?

还是我想念的一点?

1 个答案:

答案 0 :(得分:2)

查询计划不受filterPushdown配置(对于拼花或兽人)的影响。 Spark始终尝试将过滤器推送到源。配置控制是否允许源应用数据跳过。有时候,即使将config设置为true,在某些情况下也可能不会发生数据跳过(由于错误,列统计信息不正确或类型不受支持)。

您还可以在Web ui的“ SQL”标签中检查“输出行数”。

它是谓词下推和分区修剪后读取的行数。

Scan parquet

number of files read: 1
scan time total (min, med, max )
18.7 s (12 ms, 214 ms, 841 ms )
metadata time: 0 ms
size of files read: 783.9 MiB
number of output rows: 100,000,000