Skip to content

perf(spark): project no columns for an empty required schema - #19

Closed
gitRasheed wants to merge 1 commit into
developfrom
rasheed/spark-count-star-empty-projection
Closed

gitRasheed wants to merge 1 commit into
developfrom
rasheed/spark-count-star-empty-projection

Conversation

@gitRasheed

Copy link
Copy Markdown
Collaborator

Summary

count(*), count(1) and df.count() decoded every column of every file.

When Spark required no columns, VortexPartitionReader set no projection, and the native scan substitutes root() for a missing one, so it read the whole table to count rows. On a 1M-row, 18-column table, count(*) took 2.9 s; with an empty projection it takes 0.35 s.

Changes

The reader always sends a projection. For an empty required schema, NestedSchemaPruning.projection gives select([], root), which reads only row counts. Pushed filters still apply.

Testing

VortexPartitionReaderTest.emptyProjectionReadsNoColumns reads with an empty schema, with and without a pushed filter, and checks the batches have no columns and the right row counts. Fails on develop: expected: <0> but was: <3> columns.

Checked locally: ./gradlew --parallel --continue javadoc check, and :vortex-spark_2.13:test -PsparkTestVersion=4.2.0.

I used AI tools to help write and review this change.

VortexPartitionReader skipped the projection when Spark required no
columns (count(*), count(1), df.count()), and the native scan then
substituted root(), decoding every column of every file. Always send
the select, so an empty schema reads only row counts; pushed filters
still apply. Measured on a 1M-row, 18-column table: 2.9 s to 0.35 s.

Signed-off-by: gitRasheed <[email protected]>
@ChristopherWirt

Copy link
Copy Markdown
Collaborator

Closing in favor of #35. When #35 merges, the FileFormat connector replaces this reader and always sends a projection, including an empty projection for queries that require no data columns; it also supports footer-backed COUNT(*) where applicable. The equivalent behavior and regression coverage live in #35, so this old-connector implementation is superseded. This is not being closed because the change has already landed on develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants