Skip to content

Conversation

@yujun777
Copy link
Contributor

@yujun777 yujun777 commented Jul 23, 2025

What problem does this PR solve?

for sql select avg(distinct a), sum(distinct b) from t group by c, if a is not nullable, then avg is not nullable,

AvgDistinctToSumDivCount will rewrite avg to sum(distinct a) / count(distinct a), but the divide '/' is nullable,

then AdjustNullable will throw exception for this changed nullable (introduced by #52748):

AdjustNullable convert slot avg(..)#10 from not-nullable to nullable. You can disable check by set fe_debug = false.

need add a nonNullable function to make the rewritten expression not-nullable.

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 Jul 23, 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?

@yujun777
Copy link
Contributor Author

run buildall

@yujun777 yujun777 changed the title [fix](nereids) fix adjust nullable check fail [fix](nereids) fix rewrite avg to sum / count change nullable Jul 23, 2025
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17603	5268	5080	5080
q2	1924	289	188	188
q3	10313	1343	730	730
q4	10273	1052	526	526
q5	8363	2476	2339	2339
q6	208	158	132	132
q7	916	765	596	596
q8	9324	1382	1211	1211
q9	7262	5172	5176	5172
q10	6945	2390	1974	1974
q11	503	296	272	272
q12	358	353	216	216
q13	17787	3709	3101	3101
q14	238	232	222	222
q15	573	477	494	477
q16	430	429	371	371
q17	616	887	374	374
q18	7570	7150	7271	7150
q19	1463	953	571	571
q20	358	347	227	227
q21	4268	3401	3000	3000
q22	1086	1029	954	954
Total cold run time: 108381 ms
Total hot run time: 34883 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5257	5070	5154	5070
q2	254	326	223	223
q3	2185	2743	2294	2294
q4	1358	1882	1323	1323
q5	4673	4550	4509	4509
q6	211	170	127	127
q7	2029	1958	1884	1884
q8	2767	2658	2703	2658
q9	7473	7250	7376	7250
q10	3153	3313	2883	2883
q11	575	518	494	494
q12	717	771	654	654
q13	3755	4043	3323	3323
q14	279	322	295	295
q15	539	469	488	469
q16	480	487	447	447
q17	1202	1595	1428	1428
q18	8069	7861	7694	7694
q19	868	907	914	907
q20	1984	2016	1804	1804
q21	4794	4467	4415	4415
q22	1039	1027	985	985
Total cold run time: 53661 ms
Total hot run time: 51136 ms

@yujun777 yujun777 force-pushed the fix-adjust-nullable-check-fail branch from cc2d5b1 to e0b7d74 Compare July 23, 2025 10:09
@yujun777
Copy link
Contributor Author

run buildall

@yujun777 yujun777 marked this pull request as ready for review July 23, 2025 10:10
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17572	5213	5034	5034
q2	1921	278	182	182
q3	10329	1288	697	697
q4	10212	999	534	534
q5	7521	2371	2394	2371
q6	178	161	135	135
q7	897	747	626	626
q8	9329	1371	1070	1070
q9	7164	5150	5101	5101
q10	6963	2386	1987	1987
q11	479	289	267	267
q12	365	342	211	211
q13	17778	3713	3104	3104
q14	240	228	211	211
q15	582	477	499	477
q16	422	419	368	368
q17	607	877	369	369
q18	7568	7143	7247	7143
q19	1088	954	562	562
q20	359	366	219	219
q21	3747	2561	2363	2363
q22	1080	1001	955	955
Total cold run time: 106401 ms
Total hot run time: 33986 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5134	5089	5086	5086
q2	249	311	216	216
q3	2243	2664	2307	2307
q4	1328	1794	1294	1294
q5	4240	4125	4076	4076
q6	205	162	121	121
q7	1874	1808	1636	1636
q8	2506	2413	2427	2413
q9	6911	6838	6789	6789
q10	2972	3146	2716	2716
q11	554	507	481	481
q12	637	709	551	551
q13	3314	3751	3143	3143
q14	285	290	252	252
q15	508	466	463	463
q16	423	460	423	423
q17	1096	1494	1345	1345
q18	7255	7125	7148	7125
q19	764	821	955	821
q20	1925	1929	1805	1805
q21	4864	4308	4359	4308
q22	1121	1047	982	982
Total cold run time: 50408 ms
Total hot run time: 48353 ms

@yujun777 yujun777 force-pushed the fix-adjust-nullable-check-fail branch from e0b7d74 to d06eea6 Compare July 23, 2025 10:37
@doris-robot
Copy link

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

query1	994	401	390	390
query2	6020	1778	1762	1762
query3	3922	229	221	221
query4	25943	23655	23028	23028
query5	4301	619	482	482
query6	307	228	208	208
query7	4391	494	299	299
query8	292	235	224	224
query9	7018	2878	2866	2866
query10	468	331	305	305
query11	16072	15042	14900	14900
query12	172	115	110	110
query13	1516	539	411	411
query14	8121	5889	5916	5889
query15	201	191	169	169
query16	7637	628	440	440
query17	1098	733	579	579
query18	2017	413	325	325
query19	189	196	172	172
query20	127	124	117	117
query21	211	120	114	114
query22	4165	4463	4163	4163
query23	33914	32962	33151	32962
query24	8141	2361	2343	2343
query25	529	481	433	433
query26	1237	268	160	160
query27	2730	525	353	353
query28	4323	2216	2183	2183
query29	712	557	437	437
query30	287	222	188	188
query31	916	830	774	774
query32	82	78	81	78
query33	554	369	331	331
query34	799	850	525	525
query35	785	840	755	755
query36	978	1008	944	944
query37	121	111	96	96
query38	4075	4181	4036	4036
query39	1485	1421	1428	1421
query40	234	131	122	122
query41	74	61	62	61
query42	130	115	108	108
query43	500	519	478	478
query44	1364	874	864	864
query45	177	173	174	173
query46	849	1011	641	641
query47	1757	1851	1793	1793
query48	392	436	332	332
query49	745	536	391	391
query50	641	685	420	420
query51	5535	5456	5497	5456
query52	116	110	109	109
query53	237	269	186	186
query54	595	610	524	524
query55	89	86	87	86
query56	320	315	310	310
query57	1181	1179	1144	1144
query58	272	276	272	272
query59	2759	2670	2609	2609
query60	349	344	330	330
query61	128	124	170	124
query62	812	711	649	649
query63	222	191	189	189
query64	4195	1011	683	683
query65	4271	4171	4186	4171
query66	1078	432	331	331
query67	15896	16113	15517	15517
query68	7750	916	570	570
query69	511	331	290	290
query70	1208	1155	1164	1155
query71	424	350	306	306
query72	5586	4792	4754	4754
query73	617	626	363	363
query74	9052	8789	8648	8648
query75	3240	3099	2675	2675
query76	3402	1170	719	719
query77	481	399	326	326
query78	9920	10221	9298	9298
query79	2014	829	598	598
query80	658	532	473	473
query81	491	261	225	225
query82	200	135	107	107
query83	251	246	231	231
query84	243	117	93	93
query85	762	358	318	318
query86	342	323	311	311
query87	4408	4444	4245	4245
query88	2873	2258	2240	2240
query89	384	316	288	288
query90	1980	227	228	227
query91	147	142	115	115
query92	88	73	70	70
query93	2385	963	634	634
query94	691	387	297	297
query95	395	325	309	309
query96	485	592	279	279
query97	2672	2761	2636	2636
query98	241	215	208	208
query99	1342	1410	1271	1271
Total cold run time: 267011 ms
Total hot run time: 187545 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.04
query2	0.08	0.04	0.04
query3	0.24	0.07	0.08
query4	1.63	0.11	0.11
query5	0.42	0.40	0.40
query6	1.17	0.65	0.66
query7	0.03	0.02	0.02
query8	0.05	0.03	0.03
query9	0.59	0.52	0.51
query10	0.58	0.56	0.57
query11	0.15	0.10	0.10
query12	0.14	0.11	0.12
query13	0.63	0.61	0.61
query14	0.81	0.85	0.82
query15	0.89	0.87	0.86
query16	0.39	0.39	0.39
query17	1.10	1.04	1.05
query18	0.22	0.20	0.20
query19	1.92	1.85	1.82
query20	0.02	0.00	0.01
query21	15.45	0.95	0.56
query22	0.77	1.21	0.74
query23	14.86	1.37	0.64
query24	6.94	0.75	1.20
query25	0.49	0.28	0.07
query26	0.61	0.16	0.15
query27	0.05	0.06	0.05
query28	9.91	0.95	0.43
query29	12.57	3.94	3.25
query30	3.08	3.04	3.02
query31	2.82	0.59	0.39
query32	3.25	0.55	0.49
query33	3.08	3.22	3.10
query34	16.05	5.44	4.86
query35	4.91	4.89	4.90
query36	0.69	0.50	0.48
query37	0.09	0.07	0.07
query38	0.05	0.04	0.03
query39	0.03	0.03	0.03
query40	0.18	0.13	0.14
query41	0.07	0.02	0.02
query42	0.04	0.02	0.02
query43	0.05	0.03	0.03
Total cold run time: 107.14 s
Total hot run time: 32.58 s

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jul 24, 2025
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@morrySnow
Copy link
Contributor

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17606	5299	5176	5176
q2	1919	269	174	174
q3	10332	1289	699	699
q4	10247	1013	506	506
q5	8190	2419	2310	2310
q6	177	161	133	133
q7	886	737	596	596
q8	9294	1281	1067	1067
q9	6761	5098	5070	5070
q10	6887	2364	1965	1965
q11	468	293	280	280
q12	355	347	224	224
q13	18219	3727	3243	3243
q14	233	247	222	222
q15	557	494	483	483
q16	453	443	392	392
q17	616	904	384	384
q18	7649	7474	7064	7064
q19	1216	948	574	574
q20	354	341	231	231
q21	3965	3319	2973	2973
q22	1051	1005	944	944
Total cold run time: 107435 ms
Total hot run time: 34710 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5241	5219	5212	5212
q2	245	317	218	218
q3	2193	2704	2272	2272
q4	1408	1777	1316	1316
q5	4437	4573	4459	4459
q6	222	174	130	130
q7	2026	2004	1778	1778
q8	2661	2623	2759	2623
q9	7398	7204	7238	7204
q10	3128	3256	2912	2912
q11	591	501	498	498
q12	939	816	623	623
q13	3653	4023	3400	3400
q14	306	319	285	285
q15	515	479	479	479
q16	461	499	487	487
q17	1241	1554	1537	1537
q18	7744	7637	7537	7537
q19	782	790	776	776
q20	1970	1954	1784	1784
q21	4894	4354	4299	4299
q22	1083	1023	979	979
Total cold run time: 53138 ms
Total hot run time: 50808 ms

@doris-robot
Copy link

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

query1	986	405	408	405
query2	6505	1740	1793	1740
query3	6731	218	218	218
query4	26343	23866	23596	23596
query5	4592	633	515	515
query6	307	223	207	207
query7	4634	496	297	297
query8	279	226	219	219
query9	8582	2880	2857	2857
query10	478	336	309	309
query11	15911	15291	14766	14766
query12	172	115	106	106
query13	1657	550	419	419
query14	9608	6066	6017	6017
query15	233	185	160	160
query16	7640	616	458	458
query17	1167	750	600	600
query18	2038	418	310	310
query19	189	183	170	170
query20	141	119	113	113
query21	208	122	104	104
query22	4158	4167	3991	3991
query23	33843	33243	32865	32865
query24	8085	2382	2425	2382
query25	517	475	415	415
query26	1237	266	163	163
query27	2719	521	343	343
query28	4362	2216	2200	2200
query29	750	569	490	490
query30	289	225	190	190
query31	944	838	765	765
query32	83	74	71	71
query33	558	370	372	370
query34	796	848	518	518
query35	800	849	784	784
query36	944	1021	939	939
query37	118	103	89	89
query38	4241	4165	4060	4060
query39	1456	1418	1404	1404
query40	221	131	121	121
query41	60	59	57	57
query42	123	115	114	114
query43	514	518	506	506
query44	1351	890	850	850
query45	176	163	174	163
query46	855	1009	637	637
query47	1753	1808	1741	1741
query48	377	429	318	318
query49	744	482	432	432
query50	636	716	403	403
query51	5648	5526	5571	5526
query52	115	113	102	102
query53	239	269	197	197
query54	605	593	541	541
query55	89	89	90	89
query56	316	323	307	307
query57	1205	1199	1133	1133
query58	276	280	272	272
query59	2548	2681	2551	2551
query60	350	340	330	330
query61	126	124	127	124
query62	807	719	684	684
query63	228	240	188	188
query64	4280	1010	693	693
query65	4258	4165	4211	4165
query66	1076	419	355	355
query67	15766	15526	15521	15521
query68	7898	909	568	568
query69	554	334	288	288
query70	1241	1098	1134	1098
query71	424	343	323	323
query72	5511	4712	4688	4688
query73	654	589	352	352
query74	8864	9198	8937	8937
query75	3175	3132	2634	2634
query76	3201	1150	761	761
query77	513	393	326	326
query78	9961	10019	9298	9298
query79	2999	808	605	605
query80	653	537	477	477
query81	495	271	226	226
query82	680	138	110	110
query83	251	255	248	248
query84	252	101	92	92
query85	861	441	403	403
query86	385	323	355	323
query87	4373	4377	4345	4345
query88	3725	2281	2253	2253
query89	386	319	294	294
query90	1766	231	232	231
query91	150	149	112	112
query92	85	75	73	73
query93	2632	962	632	632
query94	691	400	301	301
query95	389	323	309	309
query96	486	587	285	285
query97	2660	2747	2663	2663
query98	234	215	238	215
query99	1332	1441	1281	1281
Total cold run time: 276524 ms
Total hot run time: 188496 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.08	0.04	0.04
query3	0.26	0.07	0.07
query4	1.61	0.10	0.10
query5	0.44	0.41	0.41
query6	1.18	0.66	0.66
query7	0.03	0.02	0.02
query8	0.05	0.04	0.03
query9	0.60	0.53	0.53
query10	0.59	0.57	0.58
query11	0.16	0.11	0.11
query12	0.14	0.12	0.12
query13	0.63	0.60	0.61
query14	0.80	0.83	0.86
query15	0.89	0.86	0.87
query16	0.39	0.39	0.39
query17	1.05	1.06	1.04
query18	0.21	0.19	0.20
query19	1.88	1.84	1.88
query20	0.01	0.01	0.01
query21	15.39	0.90	0.55
query22	0.75	1.14	0.71
query23	14.86	1.37	0.65
query24	6.32	1.79	0.94
query25	0.47	0.26	0.14
query26	0.69	0.16	0.13
query27	0.06	0.05	0.05
query28	9.63	0.98	0.44
query29	12.52	3.94	3.26
query30	3.10	3.00	3.00
query31	2.83	0.57	0.38
query32	3.24	0.55	0.48
query33	3.12	3.17	3.14
query34	15.77	5.49	4.83
query35	4.90	4.91	4.88
query36	0.70	0.50	0.49
query37	0.10	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.02	0.02
query40	0.18	0.14	0.14
query41	0.08	0.03	0.02
query42	0.03	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 105.91 s
Total hot run time: 32.86 s

@morrySnow
Copy link
Contributor

run check_coverage

@morrySnow morrySnow merged commit 8cebfde into apache:master Jul 24, 2025
29 of 31 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 24, 2025
### What problem does this PR solve?

for sql 
select avg(distinct a), sum(distinct b) from t group by c
if "a" is not nullable, then "avg" is not nullable,

AvgDistinctToSumDivCount will rewrite "avg" to
"sum(distinct a) / count(distinct a)", but the divide "/" is nullable,

then AdjustNullable will throw exception for this changed nullable
(introduced by #52748):
"AdjustNullable convert slot avg(..)#10 from not-nullable to nullable. You can disable check by set fe_debug = false."

need add a nonNullable function to make the rewritten expression not-nullable.
github-actions bot pushed a commit that referenced this pull request Jul 24, 2025
### What problem does this PR solve?

for sql 
select avg(distinct a), sum(distinct b) from t group by c
if "a" is not nullable, then "avg" is not nullable,

AvgDistinctToSumDivCount will rewrite "avg" to
"sum(distinct a) / count(distinct a)", but the divide "/" is nullable,

then AdjustNullable will throw exception for this changed nullable
(introduced by #52748):
"AdjustNullable convert slot avg(..)#10 from not-nullable to nullable. You can disable check by set fe_debug = false."

need add a nonNullable function to make the rewritten expression not-nullable.
yujun777 added a commit to yujun777/doris that referenced this pull request Jul 24, 2025
…#53787)

### What problem does this PR solve?

for sql 
select avg(distinct a), sum(distinct b) from t group by c
if "a" is not nullable, then "avg" is not nullable,

AvgDistinctToSumDivCount will rewrite "avg" to
"sum(distinct a) / count(distinct a)", but the divide "/" is nullable,

then AdjustNullable will throw exception for this changed nullable
(introduced by apache#52748):
"AdjustNullable convert slot avg(..)apache#10 from not-nullable to nullable. You can disable check by set fe_debug = false."

need add a nonNullable function to make the rewritten expression not-nullable.
morrySnow pushed a commit that referenced this pull request Jul 25, 2025
w41ter pushed a commit to w41ter/incubator-doris that referenced this pull request Jul 30, 2025
…#53787)

### What problem does this PR solve?

for sql 
select avg(distinct a), sum(distinct b) from t group by c
if "a" is not nullable, then "avg" is not nullable,

AvgDistinctToSumDivCount will rewrite "avg" to
"sum(distinct a) / count(distinct a)", but the divide "/" is nullable,

then AdjustNullable will throw exception for this changed nullable
(introduced by apache#52748):
"AdjustNullable convert slot avg(..)apache#10 from not-nullable to nullable. You can disable check by set fe_debug = false."

need add a nonNullable function to make the rewritten expression not-nullable.
zhiqiang-hhhh pushed a commit to zhiqiang-hhhh/doris that referenced this pull request Aug 4, 2025
…#53787)

### What problem does this PR solve?

for sql 
select avg(distinct a), sum(distinct b) from t group by c
if "a" is not nullable, then "avg" is not nullable,

AvgDistinctToSumDivCount will rewrite "avg" to
"sum(distinct a) / count(distinct a)", but the divide "/" is nullable,

then AdjustNullable will throw exception for this changed nullable
(introduced by apache#52748):
"AdjustNullable convert slot avg(..)apache#10 from not-nullable to nullable. You can disable check by set fe_debug = false."

need add a nonNullable function to make the rewritten expression not-nullable.
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/3.1.0-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants