jacktengg opened a new pull request, #69828:
URL: https://github.com/apache/doris/pull/69828
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Calendar month, quarter, year and YEAR_MONTH additions and
subtractions clamp dates at month end while preserving the time of day.
Consecutive input dates can therefore produce decreasing datetime values.
Treating these functions as globally monotonic lets RANGE partition pruning
remove partitions containing matching rows, such as January 29 filtered by
months_add(datetime_column, 1) < '2023-02-28 10:00:00'. Share a calendar
arithmetic monotonicity trait that retains the optimization for DATE and
single-day ranges and keeps other datetime ranges conservatively. This also
covers DATE_ADD, DATE_SUB, TIMESTAMPADD, INTERVAL expressions and
runtime-filter classification.
MONTHS_DIFF, QUARTERS_DIFF and YEARS_DIFF also fold some month-end datetime
arguments differently from BE because LocalDateTime.until adjusts the end date
before counting calendar units. Count date units first, then compare time parts
only when the remaining date fields match, preserving BE's truncation semantics
for both argument orders and all supported date-like literal types.
### Release note
Fix missing query rows caused by calendar arithmetic partition pruning and
align month, quarter and year difference constant folding with runtime results.
### Check List (For Author)
- Test: FE build with Checkstyle; 94 FE unit tests; regression tests
- Unit Test: CalendarAddSubMonotonicTest,
DateTimeExtractAndTransformTest, PartitionPrunerTest,
RuntimeFilterPruneClassifierTest, TimestampNsMonotonicityTest and
InferPredicateFromMonotonicFunctionTest
- Regression test: test_calendar_arithmetic_prune (73 generated result
checks) and test_date_function_prune; verify the new suite fails on the
original FE
- Behavior changed: Yes, retain matching rows and correct calendar
difference constants
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] 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 <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
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]