Repository navigation
Spark 4.2, Vortex: faster scans of Vortex tables - #48
Merged
Merged
Conversation
Scans offer their data columns, not only the partition source columns, to Spark's runtime filters such as dynamic pruning. A join on any key can then prune an Iceberg table, which helps unpartitioned tables most. - The Iceberg session extensions install NestedDynamicPruning. The rule drops each pruning filter whose filtering plan holds pruning filters of its own, which otherwise grow the plan exponentially through self-joined common table expressions. Scans offer data columns only when the session runs the rule. - A runtime filter drops the files whose column metrics rule it out. The scan asks for the metrics of the columns it offers. - The runtime filter on data columns reaches the file readers with the residual, so they skip row groups and chunks. An IN with more than spark.sql.iceberg.runtime-filtering.max-values values reaches them as its range. - Scans of row-level operations do not offer data columns. Spark keys the groups of rows they rewrite by every filter attribute, and a null in a data column matches no key. - spark.sql.iceberg.runtime-filtering.data-columns.enabled turns the feature off. Signed-off-by: Robert Kruszewski <github@robertk.io>
Map each split boundary to the nearest natural split of the file, so scans of neighbouring splits do not both decode the chunk that holds the boundary. Signed-off-by: Robert Kruszewski <github@robertk.io>
…ex scans Spark predicates such as CONTAINS and ENDS_WITH have no Iceberg expression, so Iceberg reads every column of every row and Spark filters afterwards. The scan builder now converts them into LIKE filters for the Vortex reader, which applies them in the scan and reads the other columns only for the rows that match. Spark still evaluates the predicates after the scan. Signed-off-by: Robert Kruszewski <github@robertk.io>
Adaptive split sizing aims for one split per shuffle partition by file bytes. A scan of a few columns of a wide table then makes many tasks that each read little data, and every task adds partial aggregation and shuffle output. The adaptive size now counts the column sizes that the manifests record for the columns the scan reads, and converts the result back to file bytes, with at least one split per core. spark.sql.iceberg.read.column-aware-split-size.enabled turns this off. Signed-off-by: Robert Kruszewski <github@robertk.io>
Adaptive split sizing now makes splits of at least spark.sql.iceberg.read.min-file-split-size (64 MB by default), unless that leaves cores without work. The share per core also gets a third more room, because bin packing cannot fill each split. Before this change, two 16 MiB pieces were slightly larger than the even share per core, so a scan of store_sales ran 60 tasks in two waves on 32 cores. It now runs 30 tasks. Signed-off-by: Robert Kruszewski <github@robertk.io>
Finer split offsets let adaptive split sizing give each core a task for tables of about 1 GB. On TPC-DS SF10 with Spark 4.2 this changes the total from 104.8 s to 96.6 s (q22 15.4 s to 4.4 s, q72 7.4 s to 4.9 s). Signed-off-by: Robert Kruszewski <github@robertk.io>
Each task found the row splits of its file from the layouts of all the columns. Use only the projected columns, or the first column when the projection is empty. Signed-off-by: Robert Kruszewski <github@robertk.io>
Integer, long and string sets go to native code as one array, rather than one Java literal expression per value. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 change. Scans offer their data columns to Spark's runtime filters, drop files by the column metrics, and give the filter to the file readers. The Iceberg session extensions install NestedDynamicPruning, which stops pruning subqueries from nesting into each other. Spark 4.1 has no partition predicates, so the scans keep their Spark 4.1 constructors and only add the data column flag. Signed-off-by: Robert Kruszewski <github@robertk.io>
…into Vortex scans Backport of the Spark 4.2 change. A CONTAINS or ENDS_WITH predicate on a string column, which has no Iceberg expression, reaches the Vortex reader as a filter that skips rows early. Spark still evaluates the predicate after the scan. Signed-off-by: Robert Kruszewski <github@robertk.io>
…columns Backport of the Spark 4.2 change. Adaptive split sizing counts only the bytes of the columns that a scan reads, from the column sizes in the file metrics. A scan of a few columns of a wide table then gets enough splits for the cluster. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 change. The share of bytes per core gets a third more room, because cuts fall on split offsets and packing cannot fill each split. Without it, a piece slightly larger than the share makes the scan take two waves of tasks. spark.sql.iceberg.read.min-file-split-size sets the smallest split. Signed-off-by: Robert Kruszewski <github@robertk.io>
A batch scan that pins its snapshot finds the names of its stats columns in the schema of that snapshot. Column-aware split sizing asked for the stats of the projected columns by their names in the table schema. After a column rename, the snapshot schema does not hold the new name, and planning failed with a NullPointerException. Spark then planned the query without runtime filters. The scan builder now gives the schema that the scan reads with to includeStats, and finds each stats column there by its field ID. The stats of a renamed column stay available. TestRuntimeFiltering.testRenamedSourceColumnTable covers this. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 fix. A batch scan that pins its snapshot finds the names of its stats columns in the schema of that snapshot. After a column rename, planning failed with a NullPointerException, and Spark planned the query without runtime filters. The scan builder now finds each stats column by its field ID in the schema that the scan reads with. TestRuntimeFiltering.testRenamedSourceColumnTable covers this. Signed-off-by: Robert Kruszewski <github@robertk.io>
spotlessApply moves the VortexLikeFilters import into order. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 change. Scans offer their data columns to Spark's runtime filters, drop files by the column metrics, and give the filter to the file readers. The Iceberg session extensions install NestedDynamicPruning, which stops pruning subqueries from nesting into each other. Spark 4.0 has no SparkRuntimeFilterableScan, so the runtime filter logic goes into SparkBatchQueryScan, which implements runtime filtering there. The scan builder finds stats columns by field ID in the schema that the scan reads with, as in the Spark 4.2 fix for renamed columns. Signed-off-by: Robert Kruszewski <github@robertk.io>
…into Vortex scans Backport of the Spark 4.2 change. The scan builder turns CONTAINS and ENDS_WITH predicates on string columns, which Iceberg expressions cannot state, into filters for the Vortex reader. Spark still evaluates these predicates after the scan. Spark 4.0 has no BaseSparkScanBuilder, so the conversion goes into SparkScanBuilder.pushPredicates. Signed-off-by: Robert Kruszewski <github@robertk.io>
…columns Backport of the Spark 4.2 change. Adaptive split sizing counts only the bytes of the columns that a scan reads, from the column sizes in the file metrics. A scan of a few columns of a wide table then gets enough splits for the cluster. The scan builder finds the stats columns by field ID in the schema that the scan reads with, as in the Spark 4.2 fix for renamed columns. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 change. Adaptive split sizing makes splits of at least spark.sql.iceberg.read.min-file-split-size, unless that leaves cores without work. The share per core also gets a third more room, because bin packing cannot fill each split. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 change. Scans offer their data columns to Spark's runtime filters, drop files by the column metrics, and give the filter to the file readers. The Iceberg session extensions install NestedDynamicPruning, which stops pruning subqueries from nesting into each other. As in Spark 4.0, the runtime filter logic goes into SparkBatchQueryScan. Spark 3.5 has no variant stats columns, so the scan builder asks only for the stats of the data filter columns. Signed-off-by: Robert Kruszewski <github@robertk.io>
…into Vortex scans Backport of the Spark 4.2 change. The scan builder turns CONTAINS and ENDS_WITH predicates on string columns, which Iceberg expressions cannot state, into filters for the Vortex reader. Spark still evaluates these predicates after the scan. As in Spark 4.0, the conversion goes into SparkScanBuilder.pushPredicates. Signed-off-by: Robert Kruszewski <github@robertk.io>
…columns Backport of the Spark 4.2 change. Adaptive split sizing counts only the bytes of the columns that a scan reads, from the column sizes in the file metrics. A scan of a few columns of a wide table then gets enough splits for the cluster. The scan builder finds the stats columns by field ID in the schema that the scan reads with, as in the Spark 4.2 fix for renamed columns. Signed-off-by: Robert Kruszewski <github@robertk.io>
Backport of the Spark 4.2 change. Adaptive split sizing makes splits of at least spark.sql.iceberg.read.min-file-split-size, unless that leaves cores without work. The share per core also gets a third more room, because bin packing cannot fill each split. Signed-off-by: Robert Kruszewski <github@robertk.io>
InputFileReadable copied each range in 1 MiB reads, and each stream came from InputFile#newStream. On S3A, each stream sent a HEAD request and each 1 MiB read sent its own GET. For TPC-DS SF100 q3, Vortex made 2649 GETs of 691 KB on average, against 472 GETs of 3.7 MB for Parquet. Read each range with one positional read. For Hadoop input files, open the streams with FileSystem#openFile, the known length and the random read policy, so that S3A sends no HEAD and one GET for each range. Signed-off-by: Robert Kruszewski <github@robertk.io>
length() took the larger of the bytes in the sink and the uncompressed Arrow size of the accepted rows. Vortex compresses well, so rolling writers closed files far below the target size. The Vortex writer now estimates the size of an open file: the bytes in the sink, the compressed data that it holds, and the data that it did not compress yet, scaled by the compression ratio that it measured. Use that estimate. The rows of the current Arrow batch are not in the writer yet, so scale their Arrow size by the writer's compression ratio and add them. After close, length() is the file size. Signed-off-by: Robert Kruszewski <github@robertk.io>
A runtime filter on a data column delays the scan until its subquery completes. The Vortex reader drops the rows that the filter rules out, which is worth that delay: TPC-DS at SF100 on Vortex takes 218 s with these filters and 357 s without them. The Parquet reader keeps those rows, and the files of most tables are not clustered by the join keys, so the filter often drops nothing and only delays the scan. Scans offer data columns only for tables that write Vortex files, and only when every file of the scan is a Vortex file. spark.sql.iceberg.runtime-filtering.data-columns.enabled still turns the feature on or off for all tables. Signed-off-by: Robert Kruszewski <github@robertk.io>
…n plans A runtime filter on a data column can hold hundreds of thousands of values. The scan built the full description of its runtime filters on every call to equals, hashCode and description, and Spark calls these many times while it plans adaptively and posts plan updates. In TPC-DS q33 at SF100 the filter on ss_addr_sk holds 364,761 values, and the plan updates of one run grew to 214 MB. The scan now builds the full description once, when it applies a runtime filter, and keeps using it for equals and hashCode. Plans show a shorter description that lists at most 10 values of each IN. Signed-off-by: Robert Kruszewski <github@robertk.io>
…untime filtering spark.sql.iceberg.runtime-filtering.data-columns.formats lists the file formats whose scans offer data columns to runtime filters. The default is vortex, as before. Listing parquet lets benchmarks measure Parquet with data-column runtime filters. Signed-off-by: Robert Kruszewski <github@robertk.io>
The Vortex reader and writer on this branch use APIs that Vortex 0.94.0 publishes: the writer's size estimate and compression ratio, the splits of a set of columns, and list literals built in one native call. Until now, the branch compiled only against a local Vortex build. Generated-by: Claude Code Signed-off-by: Robert Kruszewski <github@robertk.io>
The method that opens a file was over the complexity limit of checkstyle. Generated-by: Claude Code Signed-off-by: Robert Kruszewski <github@robertk.io>
Splits start and end at chunk boundaries, so a file of one chunk gives all of its rows to one split. The tests that expect rows in each split now write files with several chunks. Generated-by: Claude Code Signed-off-by: Robert Kruszewski <github@robertk.io>
…Vortex A runtime filter on a data column delays the scan until its subquery completes. The Vortex reader drops the rows that the filter rules out, which is worth that delay: TPC-DS at SF100 on Vortex takes 218 s with these filters and 357 s without them. The Parquet reader keeps those rows, and the files of most tables are not clustered by the join keys, so the filter often drops nothing and only delays the scan. Scans offer data columns only for tables that write Vortex files, and only when every file of the scan is a Vortex file. spark.sql.iceberg.runtime-filtering.data-columns.enabled still turns the feature on or off for all tables. Signed-off-by: Robert Kruszewski <github@robertk.io>
…N lists in plans A runtime filter on a data column can hold hundreds of thousands of values. The scan built the full description of its runtime filters on every call to equals, hashCode and description, and Spark calls these many times while it plans adaptively and posts plan updates. In TPC-DS q33 at SF100 the filter on ss_addr_sk holds 364,761 values, and the plan updates of one run grew to 214 MB. The scan now builds the full description once, when it applies a runtime filter, and keeps using it for equals and hashCode. Plans show a shorter description that lists at most 10 values of each IN. Signed-off-by: Robert Kruszewski <github@robertk.io>
…umns to runtime filtering spark.sql.iceberg.runtime-filtering.data-columns.formats lists the file formats whose scans offer data columns to runtime filters. The default is vortex, as before. Listing parquet lets benchmarks measure Parquet with data-column runtime filters. Signed-off-by: Robert Kruszewski <github@robertk.io>
…Vortex A runtime filter on a data column delays the scan until its subquery completes. The Vortex reader drops the rows that the filter rules out, which is worth that delay: TPC-DS at SF100 on Vortex takes 218 s with these filters and 357 s without them. The Parquet reader keeps those rows, and the files of most tables are not clustered by the join keys, so the filter often drops nothing and only delays the scan. Scans offer data columns only for tables that write Vortex files, and only when every file of the scan is a Vortex file. spark.sql.iceberg.runtime-filtering.data-columns.enabled still turns the feature on or off for all tables. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
…N lists in plans A runtime filter on a data column can hold hundreds of thousands of values. The scan built the full description of its runtime filters on every call to equals and hashCode, and Spark calls these many times while it plans adaptively. The scan now builds the full description once, when it applies a runtime filter, and keeps using it for equals and hashCode. The string of the scan shows a shorter description that lists at most 10 values of each IN. In Spark 4.0 the plan description of the scan does not show runtime filters, so plans do not change. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
…umns to runtime filtering spark.sql.iceberg.runtime-filtering.data-columns.formats lists the file formats whose scans offer data columns to runtime filters. The default is vortex, as before. Listing parquet lets benchmarks measure Parquet with data-column runtime filters. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
…Vortex A runtime filter on a data column delays the scan until its subquery completes. The Vortex reader drops the rows that the filter rules out, which is worth that delay: TPC-DS at SF100 on Vortex takes 218 s with these filters and 357 s without them. The Parquet reader keeps those rows, and the files of most tables are not clustered by the join keys, so the filter often drops nothing and only delays the scan. Scans offer data columns only for tables that write Vortex files, and only when every file of the scan is a Vortex file. spark.sql.iceberg.runtime-filtering.data-columns.enabled still turns the feature on or off for all tables. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
…N lists in plans A runtime filter on a data column can hold hundreds of thousands of values. The scan built the full description of its runtime filters on every call to equals and hashCode, and Spark calls these many times while it plans adaptively. The scan now builds the full description once, when it applies a runtime filter, and keeps using it for equals and hashCode. The string of the scan shows a shorter description that lists at most 10 values of each IN. In Spark 3.5 the plan description of the scan does not show runtime filters, so plans do not change. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
…umns to runtime filtering spark.sql.iceberg.runtime-filtering.data-columns.formats lists the file formats whose scans offer data columns to runtime filters. The default is vortex, as before. Listing parquet lets benchmarks measure Parquet with data-column runtime filters. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
The test kept the optimizer rules as a scala.collection.immutable.Seq. With Scala 2.12 the rules are a scala.collection.Seq, so the test did not compile. The test now lets the compiler find the type, which works with Scala 2.12 and 2.13. Signed-off-by: Robert Kruszewski <github@robertk.io> Generated-by: Claude Code
The backport of string match pushdown added a branch field to SparkScanBuilder. The local variable and parameter for the branch of the scan had the same name, which checkstyle rejects. Generated-by: Claude Code Signed-off-by: Robert Kruszewski <github@robertk.io>
Vortex 0.94.0 tells an empty row range apart from no range. The reader still skips the scan of a split with no rows. Generated-by: Claude Code Signed-off-by: Robert Kruszewski <github@robertk.io>
Each split read the name mapping from the Vortex file metadata. The Vortex session caches the footer but not the metadata, so every split made one more request to the object store before its scan started. The parsed mapping is now cached per file location, because data files never change. The mapping is also read before the data source opens the file, so the first open of a file can take it from the tail read that Vortex already makes. Generated-by: Claude Code
Main gained the NestedDynamicPruning rule (#49), which this branch already has. The rule keeps the branch's comments, because here it also lets scans offer data columns to dynamic pruning. The test keeps both cases: the partition column test from main and the data column test from this branch. Generated-by: Claude Code
Generated-by: Claude Code
Byte-range splits round their boundaries to the natural splits of the file. A file with one natural split then put all of its rows into one scan, and every other split of the file read nothing. Such a file now keeps the boundaries where they are, so each split reads its share of the rows. Generated-by: Claude Code
A scan of a branch reads with the table schema, but a REST catalog plans it with the schema of the snapshot that it reads. Stats columns added or renamed after that snapshot had names the catalog could not find, and planning failed with a NullPointerException on the server. The scan now requests stats only for columns that both schemas hold under the same name. Generated-by: Claude Code
robert3005
added a commit
that referenced
this pull request
Nov 25, 2026
Main gained the faster Vortex scans (#48). The scans keep the column-aware split sizing next to upstream's effective split target size metric, and the stats requests drop the variant columns, because upstream removed the plan-time shredded variant checks. Generated-by: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Faster scans of Vortex tables in Spark 3.5, 4.0, 4.1 and 4.2. Upgrades Vortex to 0.94.0.
Spark
spark.sql.iceberg.runtime-filtering.data-columns.enabled(default on) andspark.sql.iceberg.runtime-filtering.data-columns.formats(defaultvortex) control it. The Iceberg session extensions install a rule that keeps pruning filters from nesting into each other in self-joins.spark.sql.iceberg.read.column-aware-split-size.enabledandspark.sql.iceberg.read.min-file-split-size(default 64 MB) control it.CONTAINSandENDS_WITHfilters reach the Vortex reader.Vortex