Skip to content

Conversation

@zddr
Copy link
Contributor

@zddr zddr commented Oct 14, 2025

What problem does this PR solve?

Currently, a materialized view can only have one PCT table. If the reference table has multiple partitioned tables and changes occur in non-PCT tables, even if only some partitions are modified, the materialized view must be fully refreshed, which is costly.
Therefore, support for multiple PCT tables is needed, but with the following restrictions:

  • Only inner joins and unions (including UNION ALL) are supported.

  • In the case of unions, all base tables must be PCT tables; otherwise, the derivation fails.

  • The partition granularity across multiple PCT tables must align.
    For example:
    The following scenario is allowed:
    t1 has 2 partitions: [2020-01-01, 2020-01-02), [2020-01-02, 2020-01-03)
    t2 has 2 partitions: [2020-01-02, 2020-01-03), [2020-01-03, 2020-01-04)

    The following scenario is not allowed:
    t1 has 2 partitions: [2020-01-01, 2020-01-03), [2020-01-03, 2020-01-05)
    t2 has 2 partitions: [2020-01-01, 2020-01-02), [2020-01-02, 2020-01-03)

    However, if the materialized view uses monthly partition roll-up, the above scenario is allowed,
    because the materialized view only needs to generate one partition: [2020-01-01, 2020-02-01).

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • 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
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen
Copy link
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?

@zddr zddr marked this pull request as draft October 14, 2025 09:11
zddr and others added 3 commits October 14, 2025 17:17
# Conflicts:
#	fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
#	fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVRewriteUtilTest.java
…union all input when create partition materialized view
union all input when create partition materialized view
@seawinde
Copy link
Contributor

run buildall

@doris-robot
Copy link

TPC-DS: Total hot run time: 190086 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 167adc2d43f275a369bd5b4b904a08cd5d442149, data reload: false

query1	1062	451	418	418
query2	6553	1718	1673	1673
query3	6750	225	221	221
query4	26208	23669	23066	23066
query5	4862	648	496	496
query6	342	266	228	228
query7	4663	494	303	303
query8	309	258	264	258
query9	8722	2562	2558	2558
query10	500	336	284	284
query11	15449	15130	14973	14973
query12	199	118	115	115
query13	1688	569	437	437
query14	11503	9257	9278	9257
query15	215	195	180	180
query16	7695	641	543	543
query17	1603	764	594	594
query18	2042	411	349	349
query19	242	222	203	203
query20	135	129	187	129
query21	219	140	118	118
query22	4719	4647	4602	4602
query23	34911	33610	33919	33610
query24	8411	2494	2509	2494
query25	593	528	466	466
query26	1314	278	159	159
query27	2857	545	367	367
query28	4403	2260	2239	2239
query29	786	610	512	512
query30	307	237	201	201
query31	956	859	779	779
query32	105	77	69	69
query33	604	394	341	341
query34	812	903	555	555
query35	855	874	969	874
query36	1002	1027	934	934
query37	125	112	92	92
query38	3742	3725	3682	3682
query39	1496	1431	1438	1431
query40	222	129	112	112
query41	60	59	65	59
query42	122	114	111	111
query43	452	509	492	492
query44	1322	836	834	834
query45	187	182	179	179
query46	838	1045	640	640
query47	1807	1835	1781	1781
query48	410	405	326	326
query49	746	485	418	418
query50	639	678	404	404
query51	3962	3923	3826	3826
query52	104	108	98	98
query53	226	270	211	211
query54	593	596	528	528
query55	82	81	89	81
query56	341	311	302	302
query57	1189	1213	1132	1132
query58	284	272	275	272
query59	2568	2609	2519	2519
query60	330	344	330	330
query61	159	149	149	149
query62	801	772	671	671
query63	231	194	184	184
query64	4404	1127	848	848
query65	4052	4001	3958	3958
query66	1084	422	331	331
query67	15427	15191	15200	15191
query68	7872	920	595	595
query69	489	313	287	287
query70	1343	1260	1321	1260
query71	442	344	319	319
query72	5947	4949	4806	4806
query73	629	568	356	356
query74	8867	9300	8672	8672
query75	3389	3360	2840	2840
query76	3320	1145	726	726
query77	526	393	329	329
query78	9627	9692	8986	8986
query79	2645	831	605	605
query80	700	559	511	511
query81	527	261	229	229
query82	471	157	127	127
query83	263	265	248	248
query84	253	125	93	93
query85	932	467	415	415
query86	380	312	302	302
query87	3728	3874	3666	3666
query88	3752	2250	2244	2244
query89	390	332	300	300
query90	1982	278	227	227
query91	194	163	137	137
query92	87	70	67	67
query93	2250	977	638	638
query94	725	448	324	324
query95	405	324	305	305
query96	488	593	281	281
query97	2947	2976	2887	2887
query98	235	208	208	208
query99	1361	1402	1299	1299
Total cold run time: 278767 ms
Total hot run time: 190086 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 30.38 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 167adc2d43f275a369bd5b4b904a08cd5d442149, data reload: false

query1	0.06	0.05	0.05
query2	0.09	0.05	0.06
query3	0.25	0.08	0.08
query4	1.61	0.11	0.12
query5	0.29	0.26	0.26
query6	1.18	0.66	0.67
query7	0.03	0.03	0.02
query8	0.06	0.04	0.04
query9	0.63	0.54	0.52
query10	0.58	0.59	0.61
query11	0.17	0.12	0.11
query12	0.14	0.12	0.11
query13	0.63	0.62	0.62
query14	1.04	1.02	1.02
query15	0.87	0.87	0.86
query16	0.40	0.41	0.41
query17	1.09	1.04	1.03
query18	0.23	0.21	0.20
query19	2.00	1.87	1.90
query20	0.02	0.02	0.01
query21	15.39	0.90	0.57
query22	0.76	1.08	0.60
query23	15.11	1.36	0.61
query24	7.24	1.14	0.73
query25	0.49	0.24	0.07
query26	0.54	0.16	0.13
query27	0.06	0.06	0.05
query28	8.74	1.39	0.92
query29	12.58	3.99	3.33
query30	0.29	0.14	0.12
query31	2.83	0.60	0.38
query32	3.24	0.56	0.49
query33	3.19	3.10	3.20
query34	16.17	5.44	4.88
query35	4.95	4.88	4.90
query36	0.70	0.52	0.51
query37	0.10	0.08	0.08
query38	0.06	0.05	0.05
query39	0.04	0.03	0.03
query40	0.17	0.15	0.15
query41	0.09	0.03	0.03
query42	0.04	0.02	0.03
query43	0.05	0.04	0.03
Total cold run time: 104.2 s
Total hot run time: 30.38 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 41.08% (334/813) 🎉
Increment coverage report
Complete coverage report

@seawinde
Copy link
Contributor

run buildall

@doris-robot
Copy link

ClickBench: Total hot run time: 30.94 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 87cfeb00b8f425100cb0dd43a965583b0d4a9250, data reload: false

query1	0.05	0.06	0.05
query2	0.09	0.06	0.05
query3	0.25	0.08	0.08
query4	1.61	0.12	0.12
query5	0.27	0.27	0.25
query6	1.17	0.64	0.65
query7	0.03	0.03	0.03
query8	0.05	0.04	0.04
query9	0.62	0.52	0.52
query10	0.59	0.58	0.58
query11	0.19	0.11	0.12
query12	0.16	0.12	0.12
query13	0.63	0.62	0.62
query14	1.02	1.03	1.00
query15	0.87	0.84	0.85
query16	0.41	0.40	0.39
query17	1.08	1.08	1.06
query18	0.22	0.20	0.20
query19	1.91	1.78	1.86
query20	0.02	0.01	0.02
query21	15.46	0.93	0.58
query22	0.76	1.16	1.13
query23	14.67	1.39	0.68
query24	7.12	0.80	1.58
query25	0.46	0.21	0.14
query26	0.57	0.17	0.13
query27	0.07	0.05	0.05
query28	9.55	1.33	0.92
query29	12.56	3.94	3.28
query30	0.28	0.15	0.12
query31	2.83	0.63	0.38
query32	3.22	0.58	0.47
query33	3.10	3.14	3.12
query34	16.21	5.48	4.84
query35	4.92	4.94	4.91
query36	0.71	0.51	0.52
query37	0.10	0.08	0.08
query38	0.06	0.05	0.04
query39	0.03	0.03	0.03
query40	0.17	0.15	0.15
query41	0.09	0.04	0.03
query42	0.04	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 104.27 s
Total hot run time: 30.94 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 58.93% (574/974) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 75.67% (737/974) 🎉
Increment coverage report
Complete coverage report

@zddr
Copy link
Contributor Author

zddr commented Oct 16, 2025

run buildall

@doris-robot
Copy link

TPC-DS: Total hot run time: 190567 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 1be567da2ef85baa93d7fe0fb87edcdc3bee34a7, data reload: false

query1	1078	435	395	395
query2	6576	1714	1734	1714
query3	6755	226	218	218
query4	27091	23743	23599	23599
query5	5073	655	503	503
query6	365	226	225	225
query7	4655	496	301	301
query8	316	264	264	264
query9	8694	2578	2559	2559
query10	538	348	291	291
query11	15532	15211	15262	15211
query12	192	123	117	117
query13	1697	566	489	489
query14	12323	9135	9206	9135
query15	205	194	176	176
query16	7668	700	465	465
query17	1471	797	660	660
query18	2103	496	342	342
query19	218	262	177	177
query20	133	144	136	136
query21	227	139	122	122
query22	4951	4701	4561	4561
query23	34690	33714	33953	33714
query24	8336	2541	2485	2485
query25	599	558	523	523
query26	1379	292	163	163
query27	2868	545	386	386
query28	4366	2215	2168	2168
query29	993	628	511	511
query30	312	244	223	223
query31	949	845	770	770
query32	86	70	73	70
query33	613	388	345	345
query34	891	916	551	551
query35	874	874	806	806
query36	979	1043	928	928
query37	130	115	88	88
query38	3712	3706	3598	3598
query39	1468	1411	1403	1403
query40	223	125	119	119
query41	60	57	59	57
query42	131	116	119	116
query43	491	495	478	478
query44	1325	824	812	812
query45	177	187	178	178
query46	871	1002	626	626
query47	1802	1791	1747	1747
query48	394	416	314	314
query49	783	511	420	420
query50	638	684	418	418
query51	3933	3960	3811	3811
query52	117	112	99	99
query53	243	261	195	195
query54	609	588	523	523
query55	86	84	84	84
query56	326	325	296	296
query57	1207	1166	1133	1133
query58	293	283	274	274
query59	2508	2679	2591	2591
query60	349	339	336	336
query61	153	152	153	152
query62	798	747	662	662
query63	234	191	191	191
query64	4583	1162	826	826
query65	4074	3976	3989	3976
query66	1088	425	331	331
query67	15546	15170	14919	14919
query68	8005	929	588	588
query69	492	317	291	291
query70	1343	1326	1333	1326
query71	495	339	315	315
query72	5849	4936	4899	4899
query73	624	565	353	353
query74	8851	8896	9009	8896
query75	3814	3319	2774	2774
query76	3509	1182	731	731
query77	780	410	310	310
query78	9624	9750	8866	8866
query79	2045	844	590	590
query80	630	581	548	548
query81	510	261	232	232
query82	476	170	136	136
query83	267	272	254	254
query84	255	118	102	102
query85	889	477	424	424
query86	339	298	320	298
query87	3693	3731	3627	3627
query88	3575	2236	2255	2236
query89	398	321	308	308
query90	2045	211	218	211
query91	165	173	136	136
query92	87	74	70	70
query93	1163	995	647	647
query94	727	442	303	303
query95	409	323	311	311
query96	488	579	283	283
query97	2953	2998	2911	2911
query98	245	222	211	211
query99	1365	1419	1304	1304
Total cold run time: 280258 ms
Total hot run time: 190567 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 30.23 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 1be567da2ef85baa93d7fe0fb87edcdc3bee34a7, data reload: false

query1	0.06	0.05	0.05
query2	0.09	0.05	0.06
query3	0.26	0.09	0.09
query4	1.61	0.12	0.12
query5	0.28	0.27	0.26
query6	1.19	0.66	0.64
query7	0.03	0.03	0.03
query8	0.06	0.05	0.05
query9	0.65	0.54	0.52
query10	0.59	0.62	0.57
query11	0.17	0.11	0.12
query12	0.15	0.11	0.12
query13	0.65	0.62	0.61
query14	1.02	1.05	1.01
query15	0.87	0.87	0.86
query16	0.41	0.39	0.39
query17	1.04	1.05	1.06
query18	0.22	0.19	0.20
query19	1.97	1.86	1.80
query20	0.01	0.01	0.02
query21	15.43	0.97	0.57
query22	0.77	1.11	0.94
query23	14.70	1.42	0.65
query24	7.12	1.88	0.37
query25	0.38	0.22	0.07
query26	0.54	0.17	0.13
query27	0.08	0.05	0.05
query28	9.42	1.36	0.93
query29	12.55	3.91	3.31
query30	0.30	0.14	0.12
query31	2.82	0.58	0.40
query32	3.25	0.57	0.50
query33	3.10	3.07	3.14
query34	16.06	5.50	4.82
query35	4.92	4.90	4.90
query36	0.70	0.56	0.49
query37	0.10	0.07	0.08
query38	0.07	0.05	0.05
query39	0.04	0.03	0.03
query40	0.18	0.15	0.15
query41	0.08	0.03	0.03
query42	0.04	0.04	0.03
query43	0.04	0.03	0.04
Total cold run time: 104.02 s
Total hot run time: 30.23 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 57.89% (565/976) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 59.93% (643/1073) 🎉
Increment coverage report
Complete coverage report

@seawinde
Copy link
Contributor

run buildall

@doris-robot
Copy link

ClickBench: Total hot run time: 28.06 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 0e43d2bcdb6f483ab6dd2cdd929f003fefef52f3, data reload: false

query1	0.05	0.05	0.05
query2	0.10	0.05	0.05
query3	0.26	0.08	0.09
query4	1.61	0.12	0.12
query5	0.29	0.26	0.26
query6	1.19	0.66	0.64
query7	0.03	0.03	0.03
query8	0.06	0.04	0.04
query9	0.62	0.53	0.52
query10	0.59	0.57	0.58
query11	0.16	0.12	0.12
query12	0.19	0.12	0.12
query13	0.61	0.60	0.60
query14	1.01	1.02	1.03
query15	0.84	0.84	0.85
query16	0.38	0.39	0.40
query17	1.07	1.05	1.03
query18	0.21	0.21	0.20
query19	1.86	1.77	1.78
query20	0.01	0.02	0.02
query21	15.46	0.20	0.13
query22	5.07	0.07	0.05
query23	15.67	0.27	0.11
query24	2.56	0.85	0.90
query25	0.08	0.06	0.06
query26	0.14	0.13	0.13
query27	0.07	0.06	0.05
query28	4.86	1.16	0.93
query29	12.56	4.09	3.31
query30	0.27	0.15	0.13
query31	2.84	0.59	0.38
query32	3.29	0.56	0.47
query33	3.08	3.03	3.11
query34	15.89	5.20	4.54
query35	4.58	4.60	4.55
query36	0.68	0.51	0.50
query37	0.10	0.07	0.07
query38	0.07	0.04	0.04
query39	0.03	0.03	0.03
query40	0.18	0.14	0.13
query41	0.08	0.04	0.03
query42	0.03	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 98.77 s
Total hot run time: 28.06 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 77.27% (843/1091) 🎉
Increment coverage report
Complete coverage report

@zddr zddr marked this pull request as ready for review October 24, 2025 08:48
@zddr zddr changed the title [draft]Mtmv multi pct tables [feature](mtmv)Mtmv refresh support multi pct tables Oct 24, 2025
@zddr zddr changed the title [feature](mtmv)Mtmv refresh support multi pct tables [feature](mtmv)MTMV refresh support multi pct tables Oct 24, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Oct 24, 2025
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@morrySnow morrySnow merged commit a0ecbae into apache:master Oct 30, 2025
47 checks passed
dwdwqfwe pushed a commit to dwdwqfwe/doris that referenced this pull request Oct 31, 2025
### What problem does this PR solve?

Currently, a materialized view can only have one PCT table. If the
reference table has multiple partitioned tables and changes occur in
non-PCT tables, even if only some partitions are modified, the
materialized view must be fully refreshed, which is costly.
Therefore, support for multiple PCT tables is needed, but with the
following restrictions:
- Only inner joins and unions (including UNION ALL) are supported.  
- In the case of unions, all base tables must be PCT tables; otherwise,
the derivation fails.
- The partition granularity across multiple PCT tables must align.  
  For example:  
  The following scenario is allowed:  
t1 has 2 partitions: [2020-01-01, 2020-01-02), [2020-01-02, 2020-01-03)
t2 has 2 partitions: [2020-01-02, 2020-01-03), [2020-01-03, 2020-01-04)

  The following scenario is not allowed:  
t1 has 2 partitions: [2020-01-01, 2020-01-03), [2020-01-03, 2020-01-05)
t2 has 2 partitions: [2020-01-01, 2020-01-02), [2020-01-02, 2020-01-03)

However, if the materialized view uses monthly partition roll-up, the
above scenario is allowed,
because the materialized view only needs to generate one partition:
[2020-01-01, 2020-02-01).

---------

Co-authored-by: seawinde <daydayup005@yeah.net>
Co-authored-by: seawinde <wusi@selectdb.com>
morrySnow pushed a commit that referenced this pull request Nov 10, 2025
#57558)

Related PR: #49514 #56958 

Problem Summary:

In the scenario of nested materialized view rewriting, if the underlying
materialized view is a partitioned materialized view, the rewriting of
the upper-level materialized view would fail. This PR fixes the issue.
morrySnow pushed a commit that referenced this pull request Nov 17, 2025
…ew (#57958)

### What problem does this PR solve?

Related PR: #56423 #56958

Problem Summary:

1. Fix partition trace fail when create partition mv with view and
date_trunc
2. Fix err if use data_trunc('day', col) partition column when create
partition materialized view

the mv def sql would be success after this fix

CREATE VIEW lineitem_daily_summary_view AS
SELECT 
    DATE_TRUNC('day', L_SHIPDATE) AS ship_date,
    L_RETURNFLAG,
    L_LINESTATUS,
    COUNT(*) AS order_count,
    SUM(L_QUANTITY) AS total_quantity,
    SUM(L_EXTENDEDPRICE) AS total_price,
    AVG(L_DISCOUNT) AS avg_discount
FROM lineitem
WHERE L_SHIPDATE IS NOT NULL
GROUP BY ship_date, L_RETURNFLAG, L_LINESTATUS;

mv def is as following

SELECT
    ship_date,
    L_RETURNFLAG,
    SUM(order_count) AS total_orders,
    SUM(total_quantity) AS sum_quantity,
    SUM(total_price) AS sum_price,
    AVG(avg_discount) AS average_discount
FROM lineitem_daily_summary_view
GROUP BY ship_date, L_RETURNFLAG
ORDER BY ship_date, L_RETURNFLAG, total_orders, sum_quantity, sum_price;
wyxxxcat pushed a commit to wyxxxcat/doris that referenced this pull request Nov 18, 2025
apache#57558)

Related PR: apache#49514 apache#56958 

Problem Summary:

In the scenario of nested materialized view rewriting, if the underlying
materialized view is a partitioned materialized view, the rewriting of
the upper-level materialized view would fail. This PR fixes the issue.
zddr added a commit to zddr/incubator-doris that referenced this pull request Nov 19, 2025
### What problem does this PR solve?

Currently, a materialized view can only have one PCT table. If the
reference table has multiple partitioned tables and changes occur in
non-PCT tables, even if only some partitions are modified, the
materialized view must be fully refreshed, which is costly.
Therefore, support for multiple PCT tables is needed, but with the
following restrictions:
- Only inner joins and unions (including UNION ALL) are supported.
- In the case of unions, all base tables must be PCT tables; otherwise,
the derivation fails.
- The partition granularity across multiple PCT tables must align.
  For example:
  The following scenario is allowed:
t1 has 2 partitions: [2020-01-01, 2020-01-02), [2020-01-02, 2020-01-03)
t2 has 2 partitions: [2020-01-02, 2020-01-03), [2020-01-03, 2020-01-04)

  The following scenario is not allowed:
t1 has 2 partitions: [2020-01-01, 2020-01-03), [2020-01-03, 2020-01-05)
t2 has 2 partitions: [2020-01-01, 2020-01-02), [2020-01-02, 2020-01-03)

However, if the materialized view uses monthly partition roll-up, the
above scenario is allowed,
because the materialized view only needs to generate one partition:
[2020-01-01, 2020-02-01).

---------

Co-authored-by: seawinde <daydayup005@yeah.net>
Co-authored-by: seawinde <wusi@selectdb.com>
# Conflicts:
#	fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
#	fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRewriteUtil.java
#	fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
#	fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVRewriteUtilTest.java
zddr pushed a commit to zddr/incubator-doris that referenced this pull request Nov 19, 2025
…ew (apache#57958)

### What problem does this PR solve?

Related PR: apache#56423 apache#56958

Problem Summary:

1. Fix partition trace fail when create partition mv with view and
date_trunc
2. Fix err if use data_trunc('day', col) partition column when create
partition materialized view

the mv def sql would be success after this fix

CREATE VIEW lineitem_daily_summary_view AS
SELECT 
    DATE_TRUNC('day', L_SHIPDATE) AS ship_date,
    L_RETURNFLAG,
    L_LINESTATUS,
    COUNT(*) AS order_count,
    SUM(L_QUANTITY) AS total_quantity,
    SUM(L_EXTENDEDPRICE) AS total_price,
    AVG(L_DISCOUNT) AS avg_discount
FROM lineitem
WHERE L_SHIPDATE IS NOT NULL
GROUP BY ship_date, L_RETURNFLAG, L_LINESTATUS;

mv def is as following

SELECT
    ship_date,
    L_RETURNFLAG,
    SUM(order_count) AS total_orders,
    SUM(total_quantity) AS sum_quantity,
    SUM(total_price) AS sum_price,
    AVG(avg_discount) AS average_discount
FROM lineitem_daily_summary_view
GROUP BY ship_date, L_RETURNFLAG
ORDER BY ship_date, L_RETURNFLAG, total_orders, sum_quantity, sum_price;
yiguolei pushed a commit that referenced this pull request Nov 20, 2025
pick: #56958
#57713
#57759
#57681
#57958

---------

Co-authored-by: seawinde <daydayup005@yeah.net>
Co-authored-by: seawinde <wusi@selectdb.com>
seawinde added a commit to seawinde/doris that referenced this pull request Nov 24, 2025
apache#57558)

Related PR: apache#49514 apache#56958

Problem Summary:

In the scenario of nested materialized view rewriting, if the underlying
materialized view is a partitioned materialized view, the rewriting of
the upper-level materialized view would fail. This PR fixes the issue.
seawinde added a commit to seawinde/doris that referenced this pull request Nov 24, 2025
apache#57558)

Related PR: apache#49514 apache#56958 

Problem Summary:

In the scenario of nested materialized view rewriting, if the underlying
materialized view is a partitioned materialized view, the rewriting of
the upper-level materialized view would fail. This PR fixes the issue.
nagisa-kunhah pushed a commit to nagisa-kunhah/doris that referenced this pull request Dec 14, 2025
…ew (apache#57958)

### What problem does this PR solve?

Related PR: apache#56423 apache#56958

Problem Summary:

1. Fix partition trace fail when create partition mv with view and
date_trunc
2. Fix err if use data_trunc('day', col) partition column when create
partition materialized view

the mv def sql would be success after this fix

CREATE VIEW lineitem_daily_summary_view AS
SELECT 
    DATE_TRUNC('day', L_SHIPDATE) AS ship_date,
    L_RETURNFLAG,
    L_LINESTATUS,
    COUNT(*) AS order_count,
    SUM(L_QUANTITY) AS total_quantity,
    SUM(L_EXTENDEDPRICE) AS total_price,
    AVG(L_DISCOUNT) AS avg_discount
FROM lineitem
WHERE L_SHIPDATE IS NOT NULL
GROUP BY ship_date, L_RETURNFLAG, L_LINESTATUS;

mv def is as following

SELECT
    ship_date,
    L_RETURNFLAG,
    SUM(order_count) AS total_orders,
    SUM(total_quantity) AS sum_quantity,
    SUM(total_price) AS sum_price,
    AVG(avg_discount) AS average_discount
FROM lineitem_daily_summary_view
GROUP BY ship_date, L_RETURNFLAG
ORDER BY ship_date, L_RETURNFLAG, total_orders, sum_quantity, sum_price;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.2-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants