Skip to content

branch-4.2 [fix](fd) Fold function projections over uniform constants for predicate pruning - #68205

Open
englefly wants to merge 1 commit into
apache:branch-4.2from
englefly:pick-66906-4.2
Open

englefly wants to merge 1 commit into
apache:branch-4.2from
englefly:pick-66906-4.2

Conversation

@englefly

Copy link
Copy Markdown
Contributor

Cherry-pick of #66906 to branch-4.2

fix Fold function projections over uniform constants for predicate pruning

… for predicate pruning (apache#66906)

### What problem does this PR solve?

Problem Summary:
A project expression that computes a function over a uniform constant
slot (e.g.
`date_sub(dt, INTERVAL 1 DAY)` where `dt` is a uniform constant slot)
did not propagate
the resulting constant: `LogicalProject.computeUniform` only handled
constant projects and
bare slot aliases, so the projected slot had no uniform value and
downstream constant
propagation could not fold predicates over it. For a join predicate like
`t1.dt = p.prev_dt` where `p.prev_dt` is such a projection, the
predicate stayed
unfolded, could not be pushed into the scan, and partition pruning
failed.

Fix:
`LogicalProject`/`PhysicalProject`/`LogicalLoadProject.computeUniform`
now fold a project
expression whose input slots are all uniform constants: the constant
values are
substituted into the expression (new helper
`ExpressionUtils.foldToConstantByUniformValues`) and the projected slot
is registered as
a uniform constant, so downstream constant propagation can fold
predicates over it and
push them into the scan for partition pruning.

### Release note

None

### Check List (For Author)

- Test: FE unit test ConstantProjectionFoldingTest (the uniform constant
source is a
filter predicate, independent of constant CTEs; asserts the outer scan
prunes to the
  expected single partition).
- Behavior changed: No
- Does this need documentation: No
@englefly
englefly requested a review from yiguolei as a code owner September 18, 2026 15:26
@englefly

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 73.91% (17/23) 🎉
Increment coverage report
Complete coverage report

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