【问题标题】:Does Spark Filter/Predicate Pushdown not working as intended in ORC file?Spark 过滤器/谓词下推在 ORC 文件中是否按预期工作?
【发布时间】:2020-01-11 08:50:14
【问题描述】:

虽然“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”后,相同的代码 sn-p 大约需要 30 秒。 奇怪的是物理计划是一样的

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

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

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

所以我觉得即使PushedFilters在Physical中填充了一些参数(不是空的)也可以读取orc文件,这并不意味着Spark实际上会执行下推谓词/过滤器?

或者有没有我遗漏的一点?

【问题讨论】:

    标签: scala apache-spark apache-spark-sql orc


    【解决方案1】:

    查询计划不受filterPushdown 配置的影响(对于 parquet 或 orc)。 Spark 总是尝试将过滤器推送到源。配置控制是否允许源应用数据跳过。有时即使配置设置为 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
    

    【讨论】:

      猜你喜欢
      • 2020-07-02
      • 1970-01-01
      • 2016-07-14
      • 2016-04-27
      • 1970-01-01
      • 2015-12-10
      • 2019-07-04
      • 2019-01-21
      • 2011-05-22
      相关资源
      最近更新 更多