Repository navigation
Commit 35b8ff8
[fix](fe) Validate partitioned IVM MV keys and distribution (apache#19)
IVM materialized views are physically created as UNIQUE_KEYS merge-on-write tables and use the hidden row-id column as the stable dedup identity. The create path needed to align partition keys and distribution validation with that physical layout.
Root cause: In `CreateMTMVInfo.analyze()` and `MTMVPlanUtil.analyzeIvmKeys()`, IVM CREATE analysis did not fully reuse ordinary MOW partition validation and user-visible distribution needed to be validated before rewriting the physical distribution to the hidden row-id column.
| File | Change Description |
|------|--------------------|
| `MTMVPlanUtil.java` | Adds IVM partition-aware key analysis, keeps final key columns as the schema prefix, and appends row-id as the stable MOW key. |
| `CreateMTMVInfo.java` | Validates user distribution before row-id rewrite, builds physical HASH(row-id) distribution, and reuses MOW partition key validation for IVM. |
| `LogicalPlanBuilder.java` | Keeps omitted MTMV distribution as null and only records user-written distribution descriptors. |
| `ShowCreateMTMVTest.java` / `CreateMTMVCommandTest.java` | Adds FE coverage for distribution validation, SHOW CREATE replay behavior, and MOW partition validation reuse. |
| `regression-test/suites/mtmv_p0/ivm` | Adds and updates regression cases for partitioned IVM MVs and omitted distribution. |
Design rationale: IVM must physically distribute by row-id because MOW dedup is tablet-local. User-written distribution is still analyzed before this rewrite so invalid columns and explicit RANDOM follow ordinary UNIQUE table rules. SHOW CREATE omits the hidden physical distribution so generated DDL remains re-executable.
### Release note
Fixed IVM materialized view create validation for partition keys and distribution rewrite.
### 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
Unit tests:
- `./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.CreateMTMVCommandTest`
- `./run-fe-ut.sh --run org.apache.doris.catalog.ShowCreateMTMVTest`
Regression test:
- `./run-regression-test.sh --run -d mtmv_p0/ivm -s test_ivm_partition_unique_key`1 parent 2ef687b commit 35b8ff8
12 files changed
Lines changed: 1441 additions & 202 deletions
File tree
- fe/fe-core/src
- main/java/org/apache/doris
- catalog
- mtmv
- nereids
- parser
- trees/plans/commands/info
- test/java/org/apache/doris
- catalog
- mtmv
- ivm
- nereids/trees/plans
- regression-test
- data/mtmv_p0/ivm
- suites/mtmv_p0/ivm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3855 | 3855 | | |
3856 | 3856 | | |
3857 | 3857 | | |
3858 | | - | |
3859 | | - | |
3860 | | - | |
| 3858 | + | |
3861 | 3859 | | |
3862 | 3860 | | |
3863 | | - | |
3864 | | - | |
3865 | | - | |
3866 | | - | |
3867 | | - | |
3868 | | - | |
3869 | | - | |
3870 | | - | |
3871 | | - | |
3872 | | - | |
3873 | | - | |
3874 | | - | |
| 3861 | + | |
3875 | 3862 | | |
3876 | 3863 | | |
3877 | 3864 | | |
| |||
3886 | 3873 | | |
3887 | 3874 | | |
3888 | 3875 | | |
3889 | | - | |
3890 | | - | |
3891 | | - | |
3892 | | - | |
3893 | | - | |
3894 | | - | |
3895 | | - | |
3896 | | - | |
| 3876 | + | |
| 3877 | + | |
| 3878 | + | |
| 3879 | + | |
| 3880 | + | |
| 3881 | + | |
| 3882 | + | |
3897 | 3883 | | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
| 3887 | + | |
3898 | 3888 | | |
3899 | 3889 | | |
3900 | 3890 | | |
3901 | 3891 | | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
| 3900 | + | |
| 3901 | + | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
| 3905 | + | |
| 3906 | + | |
| 3907 | + | |
| 3908 | + | |
| 3909 | + | |
| 3910 | + | |
3902 | 3911 | | |
3903 | 3912 | | |
3904 | 3913 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
36 | | - | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
0 commit comments