OIiveirra opened a new pull request, #69073:
URL: https://github.com/apache/doris/pull/69073
### What problem does this PR solve?
Issue Number: DORIS-29604 (Jira)
Problem Summary:
An outer predicate on a date arithmetic alias could be expanded and pushed
ahead of an inner filter. This evaluated `WEEKS_ADD('9999-12-31 23:59:59', 5)`
on rows that the inner `WHERE` should discard, causing E218 instead of the
expected empty result.
Preserve the alias predicate above its projection when the input contains a
filter, join, limit, or CTE consumer. Apply the same protection in logical
rewriting and physical postprocessing. CTE consumers need protection because
their predicates can be pushed into producers whose filtering conditions are
outside the consumer's input tree.
Ordinary column predicates and date aliases without a lower evaluation
boundary retain predicate pushdown and partition pruning. Overflow on rows that
actually participate in date arithmetic still raises an error.
Validation:
- FE: 14 tests passed across `DateArithmeticFilterPushDownTest`,
`postprocess.PushDownFilterThroughProjectTest`, and
`PushDownFilterThroughAggregationTest`. The new safe-pushdown tests failed
before the boundary restriction was narrowed.
- BE: `VTimestampFunctionsTest.weeks_add_v2_boundary_test` and
`weeks_add_v2_test` passed; BE arithmetic code is unchanged.
- Local regression: `test_date_expression_filter`, `doc_date_error`,
`test_cte_filter_pushdown`, and `date_function_rewrite` passed after deploying
the branch build. The new suite checks ORC/Parquet input, shared non-inlined
CTEs, valid results, real overflow, NULL, and safe date-alias pruning to one of
three partitions.
- The representative Jira SQL returned zero rows without an error on
reconstructed 200-row ORC and Parquet input. Historical DLF object bytes were
unavailable, so this is reconstructed-input validation.
- FE Checkstyle and `git diff --check` passed. These results cover the
targeted local suites.
The four additional cases mentioned in Jira have different SQL shapes and
have not been established as the same root cause; this PR addresses the
confirmed representative failure.
### Release note
Fix erroneous date arithmetic overflow errors caused by predicate pushdown
in filtered subqueries and CTEs.
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
- Behavior changed:
- [ ] No.
- [x] Yes. Date arithmetic alias predicates preserve inner filtering
boundaries; safe scan-only aliases remain eligible for pushdown.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]