scala - Spark 过滤器/谓词下推在 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", true)
所以我觉得即使PushedFilters在Physical上填充了一些参数(不是空的),我也喜欢阅读orc文件,这并不意味着Spark实际上做了下推谓词/过滤器?
还是有一点我错过了?
解决方案
查询计划不受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
推荐阅读
- c# - ASP.NET Core 3 Web 应用程序、Azure 应用服务和 ANCM 进程内处理程序加载失败
- node.js - 运行 npm install 命令时,Jenkins 构建步骤失败
- node.js - 二、nodejs HTTP请求如何一个接一个?
- javascript - 用 Jest 模拟不需要的 React 组件
- python-3.x - 在pyqt4中退出窗口并打开另一个窗口的正确方法?
- python - 给定一个方法,如何获取定义该方法的类?
- mysql - 如何直接在 MySQL 中设置 WooCommerce 运输参数?
- r - 为并行处理设置 parLapply()
- sql - (REDSHIFT) 垂直合并 / FIRST_VALUE() 作为聚合
- bash - 从 HDFS 获取前两个文件