<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Predicate_pushdown</id>
	<title>Predicate pushdown - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Predicate_pushdown"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Predicate_pushdown&amp;action=history"/>
	<updated>2026-12-06T00:07:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Predicate_pushdown&amp;diff=73&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@9783fe6</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Predicate_pushdown&amp;diff=73&amp;oldid=prev"/>
		<updated>2026-11-22T21:29:55Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@9783fe6&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Predicate pushdown&lt;br /&gt;
| also_known_as   = Filter pushdown, data skipping (at the file level)&lt;br /&gt;
| field           = Query optimization&lt;br /&gt;
| key_parts       = Data source API, file format statistics (Parquet row groups, page indexes, bloom filters), table format metadata, catalog&lt;br /&gt;
| implementations = [[Apache Spark]], [[Trino]], [[DuckDB]], [[Apache Parquet]], [[Apache Iceberg]], [[Delta Lake]]&lt;br /&gt;
| related         = [[Partition]], [[Open table format]], [[Data catalog]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-22|the v4.3.0 tag of apache/spark (connector read interfaces, PushDownUtils.scala, FileSourceStrategy.scala, SQLConf.scala, docs), EXPLAIN runs on a Spark 4.3.1-SNAPSHOT build, the parquet-format 2.12.0 Thrift definition and parquet.apache.org docs, the Apache Iceberg 1.12.0 spec and REST catalog OpenAPI definition, and the Delta Lake protocol at v4.4.1}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Predicate pushdown&amp;#039;&amp;#039;&amp;#039; is a query optimization in which an engine sends the filter conditions of a query (the predicates in a &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; clause) down to the layer that reads the data, so that rows, files or whole partitions that cannot match are never read. In an [[open lakehouse]] the predicate can travel through several layers: from the engine to the data source connector, from the connector to the file format, from the table format&amp;#039;s metadata, and sometimes to the [[data catalog]]. Each layer skips data in a different way, and a predicate may be used at one layer and not at another.&lt;br /&gt;
&lt;br /&gt;
== Engine to data source ==&lt;br /&gt;
In [[Apache Spark]], a connector built on the Data Source V2 API opts in to pushdown by implementing mix-in interfaces on its &amp;lt;code&amp;gt;ScanBuilder&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;SupportsPushDownFilters&amp;lt;/code&amp;gt; (since Spark 3.0.0) receives filters as &amp;lt;code&amp;gt;org.apache.spark.sql.sources.Filter&amp;lt;/code&amp;gt; objects.&amp;lt;ref name=&amp;quot;spdf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/java/org/apache/spark/sql/connector/read/SupportsPushDownFilters.java |title=SupportsPushDownFilters.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; &amp;lt;code&amp;gt;SupportsPushDownV2Filters&amp;lt;/code&amp;gt; (since 3.3.0) receives V2 &amp;lt;code&amp;gt;Predicate&amp;lt;/code&amp;gt; objects and is the preferred interface.&amp;lt;ref name=&amp;quot;spdv2&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/java/org/apache/spark/sql/connector/read/SupportsPushDownV2Filters.java |title=SupportsPushDownV2Filters.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Sibling interfaces push down column pruning, limits, aggregates, top-N and joins.&amp;lt;ref name=&amp;quot;readpkg&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/tree/v4.3.0/sql/catalyst/src/main/java/org/apache/spark/sql/connector/read |title=org.apache.spark.sql.connector.read package (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The source returns the predicates it cannot fully apply, and Spark evaluates those after the scan. A predicate can also be &amp;#039;&amp;#039;&amp;#039;partially&amp;#039;&amp;#039;&amp;#039; pushed: the Spark interface uses the Parquet row-group filter as its example of a filter that the source uses to skip data but that Spark must still evaluate on the rows that come back.&amp;lt;ref name=&amp;quot;spdf&amp;quot; /&amp;gt; Pushdown therefore reduces the data read; it does not always remove the &amp;lt;code&amp;gt;Filter&amp;lt;/code&amp;gt; operator from the plan.&lt;br /&gt;
&lt;br /&gt;
Spark can also push filters that it learns only at runtime. With &amp;lt;code&amp;gt;SupportsRuntimeV2Filtering&amp;lt;/code&amp;gt; (since 3.4.0), a scan can drop planned input partitions using predicates that Spark infers during execution, for example from the other side of a join.&amp;lt;ref name=&amp;quot;runtime&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/java/org/apache/spark/sql/connector/read/SupportsRuntimeV2Filtering.java |title=SupportsRuntimeV2Filtering.java (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Dynamic partition pruning, on by default (&amp;lt;code&amp;gt;spark.sql.optimizer.dynamicPartitionPruning.enabled&amp;lt;/code&amp;gt;), uses a join key to generate a predicate on a partition column.&amp;lt;ref name=&amp;quot;sqlconf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala |title=SQLConf.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For its built-in file sources, Spark sorts filters into four groups: filters on partition columns, which prune directories; filters on bucket columns, which can prune files; filters on data columns, which are pushed into the file reader; and filters that must be evaluated again after the scan.&amp;lt;ref name=&amp;quot;fss&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala |title=FileSourceStrategy.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Engine to file format ==&lt;br /&gt;
{{Main|Apache Parquet}}&lt;br /&gt;
[[Apache Parquet]] files carry statistics that a reader can compare with a predicate before decoding data:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Column chunk statistics.&amp;#039;&amp;#039;&amp;#039; The file metadata holds optional statistics for each column chunk in each row group, including minimum and maximum values and a null count.&amp;lt;ref name=&amp;quot;thrift&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/parquet-format/blob/apache-parquet-format-2.12.0/src/main/thrift/parquet.thrift |title=parquet.thrift (apache-parquet-format-2.12.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; A reader skips a row group when, for example, its maximum is below the lower bound of a range filter.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Page index.&amp;#039;&amp;#039;&amp;#039; The optional column index stores lower and upper bounds for each data page, and the offset index locates pages by row number, so a reader can skip pages inside a row group.&amp;lt;ref name=&amp;quot;pageindex&amp;quot;&amp;gt;{{Cite web |url=https://parquet.apache.org/docs/file-format/pageindex/ |title=Page Index |publisher=Apache Parquet |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Bloom filters.&amp;#039;&amp;#039;&amp;#039; Minimum and maximum values cannot rule out a value that falls inside the range. A split block bloom filter answers whether a value might be present; it can return false positives but never false negatives, which makes it useful for equality filters on high-cardinality columns.&amp;lt;ref name=&amp;quot;bloom&amp;quot;&amp;gt;{{Cite web |url=https://parquet.apache.org/docs/file-format/bloomfilter/ |title=Bloom Filter |publisher=Apache Parquet |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Spark, Parquet filter pushdown is controlled by &amp;lt;code&amp;gt;spark.sql.parquet.filterPushdown&amp;lt;/code&amp;gt; (default true); ORC has the equivalent &amp;lt;code&amp;gt;spark.sql.orc.filterPushdown&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;sparkparquet&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-data-sources-parquet.html |title=Parquet Files (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;sqlconf&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Table format metadata ==&lt;br /&gt;
Table formats keep statistics for each data file in their metadata, so an engine can skip whole files before opening any of them.&lt;br /&gt;
&lt;br /&gt;
In [[Apache Iceberg]], scan planning first skips manifests whose partition summaries show no match. For the remaining manifests, Iceberg converts the query&amp;#039;s predicates into partition predicates using the partition spec each manifest was written with, and then filters data files by the column lower and upper bounds and counts stored in the manifests.&amp;lt;ref name=&amp;quot;ispec&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/format/spec.md |title=Iceberg Table Spec (apache-iceberg-1.12.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Because partition values come from transforms, a filter on a timestamp column can prune files of a table partitioned by &amp;lt;code&amp;gt;day(ts)&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;ispec&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In [[Delta Lake]], &amp;lt;code&amp;gt;add&amp;lt;/code&amp;gt; actions in the transaction log can carry per-file statistics (record count, per-column minimum and maximum values and null counts), which the protocol describes as usable for eliminating files based on query predicates.&amp;lt;ref name=&amp;quot;dproto&amp;quot;&amp;gt;{{Cite web |url=https://github.com/delta-io/delta/blob/v4.4.1/PROTOCOL.md |title=Delta Transaction Log Protocol (v4.4.1) |publisher=Delta Lake |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Delta Lake collects these statistics automatically on write for columns up to the position set by &amp;lt;code&amp;gt;delta.dataSkippingNumIndexedCols&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;dskip&amp;quot;&amp;gt;{{Cite web |url=https://docs.delta.io/optimizations-oss/ |title=Optimizations |publisher=Delta Lake |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Catalog ==&lt;br /&gt;
Some catalogs accept predicates too. Spark pushes some partition predicates to the Hive metastore so that it lists only matching partitions (&amp;lt;code&amp;gt;spark.sql.hive.metastorePartitionPruning&amp;lt;/code&amp;gt;, default true).&amp;lt;ref name=&amp;quot;sqlconf&amp;quot; /&amp;gt; The [[Iceberg REST catalog]] specification defines a server-side scan planning endpoint (&amp;lt;code&amp;gt;planTableScan&amp;lt;/code&amp;gt;) whose request includes a filter predicate, so the catalog service can plan which files a client reads.&amp;lt;ref name=&amp;quot;rest&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/open-api/rest-catalog-open-api.yaml |title=rest-catalog-open-api.yaml (apache-iceberg-1.12.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== When pushdown does not happen ==&lt;br /&gt;
A predicate is pushed only if the engine can translate it into a form the source understands. Common reasons it stays in the engine:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Casts on the column.&amp;#039;&amp;#039;&amp;#039; Comparing a string column with a number makes Spark cast the column (&amp;lt;code&amp;gt;cast(code as bigint) = 7&amp;lt;/code&amp;gt;), which has no translation to a source filter. Only &amp;lt;code&amp;gt;IsNotNull(code)&amp;lt;/code&amp;gt; is pushed in the example below.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Functions and UDFs.&amp;#039;&amp;#039;&amp;#039; A predicate such as &amp;lt;code&amp;gt;upper(code) = &amp;#039;A&amp;#039;&amp;lt;/code&amp;gt; or a user-defined function cannot be compared with stored minimum and maximum values, so it is evaluated after the scan.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Non-deterministic expressions.&amp;#039;&amp;#039;&amp;#039; Spark does not push down non-deterministic filters, such as one that uses &amp;lt;code&amp;gt;rand()&amp;lt;/code&amp;gt;, because a source might evaluate them a different number of times than Spark does.&amp;lt;ref name=&amp;quot;pdu&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/PushDownUtils.scala |title=PushDownUtils.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;fss&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Missing statistics.&amp;#039;&amp;#039;&amp;#039; File skipping needs statistics on the filtered column; Delta Lake, for example, collects none for columns past &amp;lt;code&amp;gt;delta.dataSkippingNumIndexedCols&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;dskip&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to check ==&lt;br /&gt;
In Spark, &amp;lt;code&amp;gt;EXPLAIN&amp;lt;/code&amp;gt; shows what was pushed. For a file scan, &amp;lt;code&amp;gt;PartitionFilters&amp;lt;/code&amp;gt; lists predicates used to prune directories, &amp;lt;code&amp;gt;PushedFilters&amp;lt;/code&amp;gt; lists filters handed to the file reader, and &amp;lt;code&amp;gt;DataFilters&amp;lt;/code&amp;gt; lists data-column predicates before translation. The following output, from a Spark 4.3.1-SNAPSHOT build, shows a partition column filter, a pushed range filter, and a cast that blocks pushdown (paths shortened):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
EXPLAIN SELECT order_id FROM orders&lt;br /&gt;
WHERE order_date = DATE&amp;#039;2026-11-01&amp;#039; AND amount &amp;gt; 100;&lt;br /&gt;
&lt;br /&gt;
FileScan parquet spark_catalog.default.orders[order_id#20L,amount#21,order_date#23]&lt;br /&gt;
  DataFilters: [isnotnull(amount#21), (amount#21 &amp;gt; 100.0)],&lt;br /&gt;
  PartitionFilters: [isnotnull(order_date#23), (order_date#23 = 2026-11-01)],&lt;br /&gt;
  PushedFilters: [IsNotNull(amount), GreaterThan(amount,100.0)]&lt;br /&gt;
&lt;br /&gt;
EXPLAIN SELECT order_id FROM orders WHERE code = 7;   -- code is a STRING&lt;br /&gt;
&lt;br /&gt;
Filter (isnotnull(code#22) AND (cast(code#22 as bigint) = 7))&lt;br /&gt;
+- FileScan parquet ... PushedFilters: [IsNotNull(code)]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A filter listed in &amp;lt;code&amp;gt;PushedFilters&amp;lt;/code&amp;gt; can still appear in a &amp;lt;code&amp;gt;Filter&amp;lt;/code&amp;gt; operator above the scan, because Parquet skips data by row group and page, not by row. The plan shows what was pushed, not how much data was skipped; the SQL tab of the Spark web UI shows run-time metrics for the scan, such as &amp;lt;code&amp;gt;number of output rows&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;scan time&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;spdf&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;webui&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/web-ui.html |title=Web UI (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Partition]]&lt;br /&gt;
* [[Apache Parquet]]&lt;br /&gt;
* [[Apache Iceberg]]&lt;br /&gt;
* [[Delta Lake]]&lt;br /&gt;
* [[Open table format]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>