Conversation
uros-b
reviewed
Sep 21, 2026
uros-b
left a comment
Member
There was a problem hiding this comment.
Looks like a nice change @xiaoh1024! Adding @stevomitric to also review
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.
What changes were proposed in this pull request?
Extend
BooleanSimplificationto remove redundant integral range comparisons:Support
<,<=,>, and>=between direct Byte/Short/Int/Long attributes and non-null literals of the same type, including reversed operands and one level of nested absorption. Bounds are compared without arithmetic to avoid overflow. Casts and arbitrary expressions are excluded.Why are the changes needed?
The existing rule retains these redundant comparisons. Removing them reduces per-row evaluation. This implements the integral range subset of SPARK-31760.
Does this PR introduce any user-facing change?
Yes: eligible queries have simpler optimized plans and may execute faster. Query results, including SQL NULL semantics, are preserved. No public API or configuration changes.
How was this patch tested?
Added Catalyst and SQL tests covering operand order, inclusive/exclusive bounds, nested absorption, NULLs, integer extremes, unsupported expressions, and generated evaluation. The new contained-range regression test fails with the original rule.
On Spark 5.0.0-SNAPSHOT with Scala 2.13.18 and JDK 17.0.18:
Local synthetic-data benchmarks used 30 million cached rows and
local[2], covering filter/projection queries with 0% and 10% nulls. AND placed the wider condition first, OR placed the narrower condition first, and nested absorption placed the complex branch first. Four JVMs ran in baseline/candidate/candidate/baseline order. Median query time decreased by 3–5% for AND, 30–34% for OR, and 35–43% for nested absorption. A separate rule microbenchmark measured up to 3.2 microseconds additional time per 32-expression projection (about 8%).Was this patch authored or co-authored using generative AI tooling?
Yes.