Skip to content

Conversation

@AdamGS
Copy link
Contributor

@AdamGS AdamGS commented Jan 30, 2026

Which issue does this PR close?

Rationale for this change

Ran into this while investigating #20078, in my benchmarks this saves around %10, which can quickly add up to a few ms per query.

The benchmarking code is here, measuring it on my laptop the effect is:

tpc-ds/q76/cs/16        time:   [927.65 µs 928.86 µs 930.14 µs]
                        change: [−12.309% −11.983% −11.667%] (p = 0.00 < 0.05)
                        Performance has improved.

tpc-ds/q76/ws/16        time:   [929.00 µs 930.51 µs 932.13 µs]
                        change: [−12.102% −11.808% −11.475%] (p = 0.00 < 0.05)

tpc-ds/q76/cs/128       time:   [6.8376 ms 6.8460 ms 6.8552 ms]
                        change: [−12.626% −12.411% −12.207%] (p = 0.00 < 0.05)


tpc-ds/q76/ws/128       time:   [6.8394 ms 6.8536 ms 6.8710 ms]
                        change: [−12.039% −11.813% −11.575%] (p = 0.00 < 0.05)

What changes are included in this PR?

I've also changed [cfg(test)] to a debug assertion, which seems more in the spirit of #18001, and will make the check fail even if a test in another crate triggers, which effectively increases the coverage.

Are these changes tested?

The functionality is identical, and in addition to existing tests I've changed the defensive assertion into a debug check and ran tests for other crates that make use of this codepath (like datafusion-datasource-parquet and datafusion-pruning).

Are there any user-facing changes?

None

@github-actions github-actions bot added the physical-expr Changes to the physical-expr crates label Jan 30, 2026
Copy link
Contributor

@adriangb adriangb left a comment

Choose a reason for hiding this comment

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

Thanks!

@adriangb adriangb added this pull request to the merge queue Jan 30, 2026
Merged via the queue into apache:main with commit a02e683 Jan 30, 2026
32 checks passed
@AdamGS AdamGS deleted the adamg/reduce-simplification-traversal branch January 30, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simplify_const_expr traverses expression tree twice when once is enough

2 participants