Skip to content

Conversation

@seawinde
Copy link
Contributor

It would fail when create partition mv when contain cast and the cast target data type is same to cast source data type
such as materialized view def sql is as following
l_shipdate data type is date

        CREATE MATERIALIZED VIEW mv_10086
        BUILD IMMEDIATE REFRESH AUTO ON MANUAL
        partition by(l_shipdate_d)
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1')
        AS
        select cast(l_shipdate as DATE) as l_shipdate_d, l_partkey, l_suppkey
        from lineitem;

the pr fix this

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #44786

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

@Thearas
Copy link
Contributor

Thearas commented Oct 10, 2025

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?

@seawinde
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TPC-DS: Total hot run time: 190517 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 c1115cdfb53d6dfdd2150dab4a2fdb527d0fdc72, data reload: false

query1	1090	445	408	408
query2	6587	1673	1677	1673
query3	6757	227	219	219
query4	26145	23307	23120	23120
query5	4987	660	483	483
query6	356	246	217	217
query7	4648	485	296	296
query8	292	253	239	239
query9	8744	2543	2546	2543
query10	525	329	286	286
query11	15730	15058	15009	15009
query12	189	121	111	111
query13	1665	542	439	439
query14	11839	9290	9296	9290
query15	207	202	176	176
query16	7672	694	529	529
query17	1629	781	666	666
query18	2031	472	370	370
query19	254	218	186	186
query20	152	131	131	131
query21	229	163	133	133
query22	4559	4854	4562	4562
query23	34852	34206	33794	33794
query24	8461	2500	2547	2500
query25	590	522	460	460
query26	1422	281	159	159
query27	2888	527	359	359
query28	4777	2207	2146	2146
query29	821	653	493	493
query30	296	264	210	210
query31	965	840	774	774
query32	86	65	116	65
query33	1230	377	324	324
query34	879	859	530	530
query35	829	867	735	735
query36	1016	1087	930	930
query37	145	121	100	100
query38	3553	3545	3540	3540
query39	1468	1411	1403	1403
query40	223	126	115	115
query41	60	57	57	57
query42	116	110	113	110
query43	497	486	476	476
query44	1279	835	822	822
query45	213	180	172	172
query46	837	989	623	623
query47	1773	1795	1727	1727
query48	402	409	312	312
query49	776	501	405	405
query50	634	692	417	417
query51	3966	3936	3844	3844
query52	116	117	106	106
query53	235	269	195	195
query54	600	589	527	527
query55	92	84	80	80
query56	316	328	316	316
query57	1171	1198	1137	1137
query58	283	276	273	273
query59	2601	2619	2545	2545
query60	352	340	324	324
query61	206	192	172	172
query62	803	748	683	683
query63	234	195	197	195
query64	4505	1251	937	937
query65	4105	3977	4004	3977
query66	1109	439	368	368
query67	15637	15426	15216	15216
query68	8463	940	598	598
query69	474	314	290	290
query70	1330	1319	1329	1319
query71	479	340	321	321
query72	6048	4976	5062	4976
query73	739	650	358	358
query74	9114	9108	9073	9073
query75	4058	3357	2924	2924
query76	3678	1165	720	720
query77	821	404	309	309
query78	9631	9671	8915	8915
query79	5937	827	571	571
query80	756	591	517	517
query81	475	268	232	232
query82	708	165	130	130
query83	316	267	252	252
query84	301	113	93	93
query85	911	460	418	418
query86	354	325	299	299
query87	3844	3789	3624	3624
query88	3600	2231	2224	2224
query89	465	331	299	299
query90	2053	216	227	216
query91	156	162	129	129
query92	88	71	64	64
query93	3286	980	639	639
query94	704	445	322	322
query95	393	320	311	311
query96	485	572	290	290
query97	2928	2992	2845	2845
query98	238	221	221	221
query99	1438	1421	1279	1279
Total cold run time: 287977 ms
Total hot run time: 190517 ms

@doris-robot
Copy link

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

query1	0.06	0.04	0.04
query2	0.09	0.05	0.06
query3	0.26	0.09	0.08
query4	1.60	0.12	0.12
query5	0.27	0.26	0.26
query6	1.17	0.65	0.65
query7	0.03	0.02	0.02
query8	0.05	0.04	0.04
query9	0.63	0.53	0.51
query10	0.60	0.57	0.58
query11	0.16	0.12	0.12
query12	0.15	0.13	0.12
query13	0.64	0.61	0.62
query14	1.02	1.01	1.03
query15	0.87	0.84	0.87
query16	0.40	0.43	0.43
query17	1.08	1.11	1.09
query18	0.21	0.20	0.20
query19	1.98	1.89	1.88
query20	0.01	0.01	0.02
query21	15.42	0.95	0.58
query22	0.75	1.19	0.63
query23	15.00	1.39	0.59
query24	6.77	2.33	0.66
query25	0.52	0.14	0.09
query26	0.58	0.16	0.13
query27	0.06	0.05	0.06
query28	9.75	1.37	0.93
query29	12.62	3.92	3.29
query30	0.27	0.14	0.12
query31	2.83	0.60	0.39
query32	3.24	0.55	0.49
query33	3.18	3.10	3.17
query34	16.12	5.50	4.86
query35	4.94	4.91	4.91
query36	0.69	0.51	0.50
query37	0.11	0.09	0.07
query38	0.06	0.04	0.04
query39	0.03	0.02	0.02
query40	0.19	0.15	0.14
query41	0.08	0.03	0.03
query42	0.03	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 104.57 s
Total hot run time: 30.34 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 75.00% (3/4) 🎉
Increment coverage report
Complete coverage report

// remove sink
materializedViewPlan = materializedViewPlan.accept(new DefaultPlanRewriter<Void>() {
@Override
public Plan visitLogicalSink(LogicalSink<? extends Plan> logicalSink, Void context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need remove sink?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if mv is partitioned and partition roll up, would add date_trunc(col, unit) expr above mv def sql plan, if def sql plan is sink, would add project above sink, this would not cause err now but unreasonable

…st target data type is same to cast source data type
@seawinde seawinde force-pushed the fix_create_partition_mv_fail_when_use_cast branch from c1115cd to e80728d Compare November 12, 2025 08:15
@seawinde
Copy link
Contributor Author

run buildall

@seawinde
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 34025 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 10e873203d988f4c3d41c1cbe7dc28246ce5e624, data reload: false

------ Round 1 ----------------------------------
q1	17646	5133	4992	4992
q2	2001	312	203	203
q3	10293	1278	706	706
q4	10219	856	366	366
q5	7517	2361	2504	2361
q6	181	167	135	135
q7	917	768	620	620
q8	9346	1401	1111	1111
q9	7037	5137	5155	5137
q10	6850	2243	1824	1824
q11	493	302	280	280
q12	355	368	225	225
q13	17802	3611	2998	2998
q14	242	236	215	215
q15	591	511	500	500
q16	1017	997	958	958
q17	597	877	351	351
q18	7496	7106	7017	7017
q19	1292	950	538	538
q20	358	333	229	229
q21	3674	2560	2271	2271
q22	1065	1050	988	988
Total cold run time: 106989 ms
Total hot run time: 34025 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5100	5066	5070	5066
q2	250	344	232	232
q3	2163	2699	2351	2351
q4	1347	1804	1303	1303
q5	4167	4250	4514	4250
q6	209	175	128	128
q7	2042	1960	1871	1871
q8	2617	2562	2596	2562
q9	7293	7287	7417	7287
q10	3053	3315	2793	2793
q11	590	561	512	512
q12	647	761	653	653
q13	3582	4074	3286	3286
q14	273	288	303	288
q15	536	505	517	505
q16	1080	1141	1033	1033
q17	1191	1701	1343	1343
q18	7916	8050	7641	7641
q19	801	850	1029	850
q20	1990	2065	1855	1855
q21	4646	4378	4347	4347
q22	1100	1058	1020	1020
Total cold run time: 52593 ms
Total hot run time: 51176 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 187432 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 10e873203d988f4c3d41c1cbe7dc28246ce5e624, data reload: false

query1	1030	393	391	391
query2	6561	1697	1705	1697
query3	6758	225	218	218
query4	26732	23904	23237	23237
query5	4447	636	478	478
query6	339	242	235	235
query7	4639	495	295	295
query8	321	258	249	249
query9	8708	2592	2574	2574
query10	495	355	299	299
query11	15750	14953	14945	14945
query12	178	126	108	108
query13	1680	566	452	452
query14	11247	9120	9014	9014
query15	217	186	168	168
query16	7669	671	473	473
query17	1220	768	613	613
query18	2016	412	315	315
query19	210	198	176	176
query20	128	129	118	118
query21	216	135	121	121
query22	4076	4138	3962	3962
query23	33720	32930	33276	32930
query24	8490	2381	2387	2381
query25	586	500	441	441
query26	1237	272	170	170
query27	2762	492	350	350
query28	4376	2220	2213	2213
query29	830	645	537	537
query30	293	225	203	203
query31	901	814	719	719
query32	89	75	74	74
query33	601	400	333	333
query34	793	845	515	515
query35	803	845	768	768
query36	973	992	891	891
query37	125	109	90	90
query38	3455	3535	3436	3436
query39	1479	1421	1417	1417
query40	228	129	125	125
query41	91	82	67	67
query42	131	114	113	113
query43	478	508	475	475
query44	1230	775	727	727
query45	187	183	171	171
query46	887	991	658	658
query47	1766	1834	1746	1746
query48	389	459	323	323
query49	794	541	440	440
query50	648	682	407	407
query51	3919	3928	3922	3922
query52	107	112	105	105
query53	247	270	194	194
query54	339	303	296	296
query55	89	87	91	87
query56	367	322	305	305
query57	1168	1183	1121	1121
query58	298	325	272	272
query59	2597	2706	2622	2622
query60	336	355	314	314
query61	161	153	156	153
query62	802	706	659	659
query63	225	194	188	188
query64	4526	1160	853	853
query65	3993	3987	3949	3949
query66	1094	430	335	335
query67	15431	15274	15044	15044
query68	8466	916	607	607
query69	494	326	281	281
query70	1271	1352	1226	1226
query71	485	341	314	314
query72	5860	4879	4892	4879
query73	646	591	357	357
query74	8825	9193	8639	8639
query75	4003	3368	2816	2816
query76	3807	1149	739	739
query77	818	405	303	303
query78	9493	9833	8839	8839
query79	2014	832	617	617
query80	650	562	481	481
query81	486	262	233	233
query82	437	162	133	133
query83	264	272	260	260
query84	255	114	94	94
query85	947	490	448	448
query86	340	315	290	290
query87	3691	3750	3605	3605
query88	3670	2251	2255	2251
query89	399	338	300	300
query90	1964	225	220	220
query91	171	163	133	133
query92	78	64	63	63
query93	1279	999	654	654
query94	716	390	343	343
query95	414	328	312	312
query96	496	564	286	286
query97	2955	2974	2885	2885
query98	242	217	211	211
query99	1467	1400	1336	1336
Total cold run time: 275781 ms
Total hot run time: 187432 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.05
query2	0.09	0.04	0.04
query3	0.25	0.08	0.09
query4	1.60	0.11	0.11
query5	0.27	0.26	0.26
query6	1.17	0.65	0.63
query7	0.03	0.03	0.02
query8	0.06	0.04	0.04
query9	0.57	0.52	0.50
query10	0.57	0.58	0.58
query11	0.16	0.11	0.11
query12	0.16	0.12	0.12
query13	0.63	0.60	0.59
query14	0.99	0.99	0.99
query15	0.85	0.84	0.85
query16	0.39	0.40	0.38
query17	1.03	1.00	1.04
query18	0.21	0.20	0.20
query19	1.90	1.78	1.79
query20	0.02	0.01	0.01
query21	15.44	0.18	0.14
query22	5.04	0.08	0.05
query23	15.66	0.25	0.10
query24	2.83	1.27	0.42
query25	0.08	0.06	0.06
query26	0.15	0.14	0.14
query27	0.06	0.05	0.06
query28	4.79	1.15	0.94
query29	12.59	3.89	3.20
query30	0.30	0.13	0.11
query31	2.82	0.56	0.39
query32	3.23	0.56	0.47
query33	3.02	3.01	3.05
query34	15.91	5.11	4.55
query35	4.61	4.52	4.64
query36	0.66	0.50	0.48
query37	0.10	0.07	0.06
query38	0.07	0.04	0.04
query39	0.03	0.04	0.03
query40	0.18	0.14	0.14
query41	0.09	0.04	0.03
query42	0.04	0.02	0.02
query43	0.04	0.03	0.02
Total cold run time: 98.75 s
Total hot run time: 27.3 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

@morrySnow morrySnow closed this Nov 17, 2025
yiguolei pushed a commit to yiguolei/incubator-doris that referenced this pull request Dec 30, 2025
…st target data type is same to cast source data type apache#56804 (apache#5766)

## Proposed changes

It would fail when create partition mv when contain cast and the cast
target data type is same to cast source data type
such as materialized view def sql is as following
l_shipdate data type is `date`

```sql

        CREATE MATERIALIZED VIEW mv_10086
        BUILD IMMEDIATE REFRESH AUTO ON MANUAL
        partition by(l_shipdate_d)
        DISTRIBUTED BY RANDOM BUCKETS 2
        PROPERTIES ('replication_num' = '1')
        AS
        select cast(l_shipdate as DATE) as l_shipdate_d, l_partkey, l_suppkey
        from lineitem;
```

the pr fix this

Issue Number: close #xxx

<!--Describe your changes.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev/3.1.x dev/4.0.x usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants