Skip to content

[GLUTEN-13546][VL] Push literal-on-left comparisons into subfield filters - #13552

Merged
LuciferYang merged 1 commit into
apache:mainfrom
LuciferYang:gcfix-subfield-literal-left
Nov 11, 2026
Merged

LuciferYang merged 1 commit into
apache:mainfrom
LuciferYang:gcfix-subfield-literal-left

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

SparkExprToSubfieldFilterParser::leafCallToSubfieldFilter only recognized a column on the left side of a comparison, so a predicate such as 100 > id was never turned into a subfield filter and could not be used for row group pruning. Spark does not rewrite it, and Gluten passes the Catalyst filter to the native scan as is.

When the left operand is not a column and the right one is, the comparison is now rewritten with the operands swapped and the operator mirrored (100 > id becomes id < 100) and handled as before. This covers =, <, <=, > and >=. Results do not change, since the predicate was already evaluated as a remaining filter.

Fixes #13546.

How was this patch tested?

Added Literal-on-left comparison prunes Parquet row groups to VeloxMetricsSuite. It writes a sorted Parquet file with 10 row groups and checks that five literal-on-left predicates skip and read the same row groups as their mirrored forms. Before this change, 100 > id read all 10 row groups while id < 100 skipped 9.

Was this patch authored or co-authored using generative AI tooling?

Yes. Generated-by: Claude Opus.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 06:19
@github-actions github-actions Bot added the VELOX label Nov 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the literal-on-left comparison filtering change.

No open issues 🎉

What changed in this PR

Fixes #13546 by enabling Velox subfield filters for literal-on-left comparisons, allowing Parquet row-group pruning without changing query results.

Changes:

  • Swaps operands and mirrors the five supported comparison operators when the column is on the right.
  • Adds regression coverage comparing query results and row-group metrics for literal-on-left predicates and their mirrored forms.
File Description
cpp/​velox/​operators/​functions/​SparkExprToSubfieldFilterParser.cc Normalizes literal-on-left comparisons for existing subfield-filter handling.
backends-velox/​src/​test/​scala/​org/​apache/​gluten/​execution/​VeloxMetricsSuite.scala Tests equivalent pruning across five comparison operators.

Review effort: Balanced

@LuciferYang

Copy link
Copy Markdown
Contributor Author

@zhztheplayer @rui-mo Could you take a look? It extends the subfield filter translation in SparkExprToSubfieldFilterParser.

@LuciferYang
LuciferYang merged commit 95dc804 into apache:main Nov 11, 2026
72 checks passed
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Merge into main. Thank you @zhztheplayer

@rui-mo rui-mo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Literal-on-left comparisons are not used for Parquet row group pruning

4 participants