hakanuzum opened a new pull request, #62599:
URL: https://github.com/apache/doris/pull/62599
### What problem does this PR solve?
Issue Number: close #62395
Problem Summary: Implement 1-to-N partition mapping to support hour-offset
MTMV partition expressions (like `date_trunc(date_add(col, INTERVAL N HOUR),
'day')`) when base table partitions are aligned to UTC-midnight boundaries.
Previously, a single base partition spanning two roll-up buckets would fail;
now it correctly maps to multiple MTMV partitions.
### What is changed and how does it work?
**Core Changes:**
1. **New Partition Expression Type:** `MTMVPartitionExprDateTruncDateAddSub`
- Handles `date_trunc(date_add/sub(col, INTERVAL N hour),
'day/week/month/quarter/year')`
- Supports both positive and negative hour offsets
- Validates partition column types (DATETIME/DATETIMEV2 only)
2. **1-to-N Partition Mapping:**
- `generateRollUpPartitionKeyDescs()` returns `List<PartitionKeyDesc>`
- Iterates through all roll-up buckets between lower and upper bounds
- Each base partition can map to multiple MTMV partitions
3. **Full Lifecycle Support:**
- Union compensation: Hour-offset applied to predicates
- Refresh: Correct partition range calculation
- SQL serialization: Preserves expression structure
- Backward compatibility: Default implementation in interface
### Release note
Feature: Support hour-offset MTMV partition expressions with UTC-midnight
base partitions. Users can now create materialized views with expressions like
`date_trunc(date_add(col, INTERVAL 3 HOUR), 'day')` even when base table uses
UTC-midnight aligned partitions.
### Check List (For Author)
- Test: Regression test + Unit test
- Added comprehensive regression tests for hour-offset scenarios
- Added unit tests for 1-to-N partition mapping
- Tested UTC-midnight, aligned, and edge cases
- Negative scenarios (DATE, TIMESTAMPTZ types)
- Behavior changed: Yes
- Previously failed with alignment error; now succeeds with 1-to-N
mapping
- Does this need documentation: Yes
- User-facing feature, should document supported expressions and
limitations
--
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]