Skip to content

Conversation

@yujun777
Copy link
Contributor

@yujun777 yujun777 commented Jan 8, 2026

simplify range have exception:

mysql >  explain select pk from table_0_500_undef_partitions2_keys3_properties4_distributed_by5 where  not ( date_sub(col_date_undef_signed, interval 1 day) > '2010-03-21' or null ) or lower(col_varchar_20__undef_signed) between null and 'e';
(1105, "errCode = 2, detailMessage = Cannot compare two values with different data types: 2010-03-22 (DATEV2) vs 'e' (VARCHAR(1))")

PR #57537 introduce merging compound value with other value desc.

when merge value desc, it will merge values with the same reference.

but for compound value, its reference have other meaning:

  1. a < 1 or a > 10, this is a compound value, its reference is a;
  2. a < 1 or b > 10, this is a compound value, its reference is 'a < 1 or b > 10'.

then for expression TA > 1 and FALSE or FALSE and SB > 'abc'', for the operator OR, it will have two compound values:
a. C1 = CompoundValue(referece = getCompoundExpression(TA > 1 and FALSE) = FALSE, source values={TA > 1, FALSE})
b. C2 = CompoundValue(reference = getCompoundExpression(FALSE and SB > 'abc') = FALSE, source values={FALSE, SB > 'abc'})

because the function getCompoundExpression will fold constant, then C1 andC2's referece will be 'FALSE', and since C1 and C2's reference equals, then will try merge C1 and C2, then will check merge ' > 1' and ' > abc' will cause the above exception.

to fix this, for a compound value if its source values different reference (like a < 1 or b > 10), then don't merge it with other values descs.

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?

@yujun777
Copy link
Contributor Author

yujun777 commented Jan 8, 2026

run buildall

morrySnow
morrySnow previously approved these changes Jan 8, 2026
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

PR approved by anyone and no changes requested.

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17634	4244	4031	4031
q2	2042	350	251	251
q3	10133	1261	700	700
q4	10221	850	315	315
q5	7567	2098	1770	1770
q6	189	165	135	135
q7	950	782	662	662
q8	9269	1372	1051	1051
q9	4849	4547	4523	4523
q10	6793	1809	1395	1395
q11	526	301	301	301
q12	702	725	596	596
q13	17771	3796	3059	3059
q14	289	296	279	279
q15	573	512	500	500
q16	718	676	639	639
q17	664	757	524	524
q18	6672	6249	6692	6249
q19	1509	981	656	656
q20	444	398	276	276
q21	3241	2668	2490	2490
q22	1133	1018	1014	1014
Total cold run time: 103889 ms
Total hot run time: 31416 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4340	4249	4280	4249
q2	350	409	313	313
q3	2222	2799	2410	2410
q4	1488	1869	1428	1428
q5	4402	4589	4349	4349
q6	212	172	125	125
q7	1966	1889	1785	1785
q8	2759	2358	2344	2344
q9	6956	7003	7062	7003
q10	2458	2753	2286	2286
q11	552	471	450	450
q12	710	753	610	610
q13	3501	3813	3086	3086
q14	265	292	266	266
q15	529	495	486	486
q16	610	643	597	597
q17	1100	1372	1388	1372
q18	7238	7106	7145	7106
q19	805	773	781	773
q20	1877	1969	1820	1820
q21	4430	4250	4202	4202
q22	1082	1040	1009	1009
Total cold run time: 49852 ms
Total hot run time: 48069 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 172191 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 63f45c6eb6fc4b12208bd3cbc7bfb791dd4e60bd, data reload: false

query5	4422	587	425	425
query6	333	237	207	207
query7	4209	459	285	285
query8	339	257	248	248
query9	8743	2638	2659	2638
query10	523	387	327	327
query11	15330	15123	15034	15034
query12	187	120	116	116
query13	1293	493	381	381
query14	6443	3060	2788	2788
query14_1	2723	2833	2688	2688
query15	212	192	178	178
query16	988	455	462	455
query17	1117	697	583	583
query18	2567	436	351	351
query19	242	238	199	199
query20	129	123	115	115
query21	219	138	120	120
query22	3972	3949	4020	3949
query23	15964	15538	15067	15067
query23_1	15295	15340	15300	15300
query24	7348	1548	1197	1197
query24_1	1186	1168	1197	1168
query25	581	474	428	428
query26	1238	261	151	151
query27	2790	449	290	290
query28	4521	2130	2111	2111
query29	836	549	463	463
query30	312	243	214	214
query31	805	647	572	572
query32	81	73	69	69
query33	556	341	292	292
query34	903	891	522	522
query35	741	862	669	669
query36	866	866	835	835
query37	130	93	74	74
query38	2721	2746	2671	2671
query39	765	756	748	748
query39_1	709	743	708	708
query40	215	132	114	114
query41	70	66	67	66
query42	108	101	107	101
query43	452	486	415	415
query44	1294	735	718	718
query45	186	180	174	174
query46	840	948	594	594
query47	1397	1404	1345	1345
query48	303	319	236	236
query49	623	407	325	325
query50	626	267	203	203
query51	3803	3739	3705	3705
query52	109	110	103	103
query53	304	331	267	267
query54	280	253	246	246
query55	74	75	73	73
query56	281	293	327	293
query57	1019	1023	963	963
query58	274	243	243	243
query59	2029	2108	2130	2108
query60	342	313	300	300
query61	165	161	157	157
query62	395	349	331	331
query63	300	261	272	261
query64	4992	1292	994	994
query65	3829	3751	3710	3710
query66	1402	415	301	301
query67	14877	14618	14974	14618
query68	7021	1002	693	693
query69	522	337	303	303
query70	1062	951	951	951
query71	382	307	286	286
query72	6090	3323	3486	3323
query73	754	710	295	295
query74	8803	8774	8671	8671
query75	2825	2839	2452	2452
query76	3894	1049	640	640
query77	528	383	279	279
query78	9704	9711	9151	9151
query79	1497	890	590	590
query80	689	598	483	483
query81	511	262	227	227
query82	414	149	110	110
query83	266	254	242	242
query84	257	123	100	100
query85	897	518	458	458
query86	418	299	288	288
query87	2831	2901	2723	2723
query88	3243	2232	2214	2214
query89	378	354	327	327
query90	2209	157	145	145
query91	175	162	139	139
query92	80	69	62	62
query93	1947	906	518	518
query94	587	289	275	275
query95	580	320	350	320
query96	574	449	200	200
query97	2314	2386	2301	2301
query98	254	202	200	200
query99	590	590	551	551
Total cold run time: 254257 ms
Total hot run time: 172191 ms

@doris-robot
Copy link

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

query1	0.05	0.05	0.04
query2	0.10	0.04	0.04
query3	0.26	0.09	0.08
query4	1.61	0.12	0.12
query5	0.28	0.27	0.27
query6	1.14	0.66	0.65
query7	0.03	0.02	0.03
query8	0.06	0.04	0.04
query9	0.56	0.50	0.51
query10	0.54	0.55	0.54
query11	0.14	0.10	0.09
query12	0.14	0.10	0.10
query13	0.61	0.59	0.57
query14	0.97	0.95	0.95
query15	0.79	0.76	0.77
query16	0.39	0.41	0.39
query17	1.04	1.06	1.05
query18	0.23	0.21	0.21
query19	1.95	1.81	1.77
query20	0.02	0.01	0.01
query21	15.44	0.26	0.14
query22	5.35	0.05	0.05
query23	15.68	0.29	0.10
query24	1.22	0.26	0.59
query25	0.10	0.06	0.06
query26	0.14	0.14	0.13
query27	0.06	0.06	0.05
query28	3.94	1.05	0.88
query29	12.57	3.96	3.19
query30	0.28	0.14	0.12
query31	2.81	0.64	0.40
query32	3.23	0.56	0.45
query33	3.00	3.01	3.06
query34	16.75	5.11	4.50
query35	4.49	4.52	4.47
query36	0.66	0.53	0.49
query37	0.11	0.07	0.06
query38	0.08	0.05	0.03
query39	0.04	0.03	0.03
query40	0.18	0.15	0.13
query41	0.08	0.03	0.03
query42	0.04	0.03	0.04
query43	0.05	0.04	0.03
Total cold run time: 97.21 s
Total hot run time: 26.84 s

@yujun777
Copy link
Contributor Author

yujun777 commented Jan 8, 2026

run buildall

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Jan 8, 2026
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17660	4201	4046	4046
q2	2017	357	230	230
q3	10178	1319	712	712
q4	10203	770	312	312
q5	7524	2100	1789	1789
q6	187	166	138	138
q7	1034	809	664	664
q8	9265	1383	1144	1144
q9	4754	4700	4596	4596
q10	6731	1803	1419	1419
q11	504	313	302	302
q12	688	778	595	595
q13	17771	3799	3104	3104
q14	302	314	273	273
q15	582	507	500	500
q16	706	685	641	641
q17	674	768	537	537
q18	7027	6529	6920	6529
q19	1119	1035	633	633
q20	429	393	259	259
q21	3245	2607	2584	2584
q22	1114	1096	1036	1036
Total cold run time: 103714 ms
Total hot run time: 32043 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4296	4368	4268	4268
q2	322	390	333	333
q3	2260	2866	2336	2336
q4	1447	1870	1483	1483
q5	4402	4415	4256	4256
q6	221	167	134	134
q7	1982	1905	1756	1756
q8	2526	2602	2350	2350
q9	6990	7340	7199	7199
q10	2452	2730	2237	2237
q11	566	504	469	469
q12	689	762	619	619
q13	3632	4018	3308	3308
q14	268	276	256	256
q15	521	492	493	492
q16	634	650	660	650
q17	1101	1278	1342	1278
q18	7481	7401	7238	7238
q19	835	788	773	773
q20	1883	1952	1803	1803
q21	4475	4225	4092	4092
q22	1062	1030	954	954
Total cold run time: 50045 ms
Total hot run time: 48284 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 171909 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 05feb05024464859a6c32d12dba5cdc634377748, data reload: false

query5	4838	573	436	436
query6	341	215	216	215
query7	4211	447	257	257
query8	337	238	222	222
query9	8760	2631	2622	2622
query10	535	381	314	314
query11	15246	15108	14883	14883
query12	173	113	114	113
query13	1274	480	379	379
query14	6394	3056	2743	2743
query14_1	2711	2642	2686	2642
query15	201	195	174	174
query16	981	473	366	366
query17	1063	688	570	570
query18	2617	446	349	349
query19	235	225	201	201
query20	125	119	115	115
query21	215	144	132	132
query22	4029	3932	3742	3742
query23	16038	15683	15219	15219
query23_1	15346	15615	15369	15369
query24	7361	1542	1165	1165
query24_1	1213	1174	1202	1174
query25	576	476	434	434
query26	1245	266	160	160
query27	2754	451	290	290
query28	4541	2154	2149	2149
query29	836	568	461	461
query30	328	242	216	216
query31	857	623	540	540
query32	80	75	67	67
query33	563	354	298	298
query34	885	890	517	517
query35	709	836	679	679
query36	869	871	757	757
query37	120	91	75	75
query38	2746	2827	2739	2739
query39	772	739	734	734
query39_1	716	699	701	699
query40	216	130	113	113
query41	66	64	61	61
query42	111	102	104	102
query43	438	448	437	437
query44	1311	716	726	716
query45	188	181	174	174
query46	838	960	591	591
query47	1336	1465	1356	1356
query48	306	328	237	237
query49	597	414	330	330
query50	649	276	200	200
query51	3832	3806	3764	3764
query52	104	108	97	97
query53	291	320	271	271
query54	284	263	239	239
query55	77	71	74	71
query56	290	288	286	286
query57	963	1029	951	951
query58	282	305	248	248
query59	1982	2211	2083	2083
query60	314	311	284	284
query61	157	168	162	162
query62	410	350	311	311
query63	299	268	273	268
query64	4951	1326	1015	1015
query65	3787	3722	3704	3704
query66	1407	406	305	305
query67	15133	14734	15542	14734
query68	8027	990	701	701
query69	509	346	304	304
query70	1065	934	982	934
query71	373	295	274	274
query72	5972	3359	3417	3359
query73	764	717	306	306
query74	8724	8836	8604	8604
query75	2828	2827	2435	2435
query76	3922	1068	635	635
query77	498	368	283	283
query78	9690	9747	9236	9236
query79	1478	911	560	560
query80	648	566	466	466
query81	510	263	228	228
query82	209	144	110	110
query83	257	248	238	238
query84	260	121	97	97
query85	892	514	459	459
query86	386	323	322	322
query87	2824	2882	2808	2808
query88	3107	2216	2190	2190
query89	386	353	333	333
query90	2163	152	154	152
query91	177	173	144	144
query92	81	68	63	63
query93	2074	907	520	520
query94	576	312	291	291
query95	573	328	301	301
query96	578	448	199	199
query97	2327	2441	2309	2309
query98	234	203	206	203
query99	569	576	483	483
Total cold run time: 255175 ms
Total hot run time: 171909 ms

@yujun777
Copy link
Contributor Author

yujun777 commented Jan 8, 2026

run cloud_p0

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 93.33% (14/15) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 93.33% (14/15) 🎉
Increment coverage report
Complete coverage report

@yujun777
Copy link
Contributor Author

yujun777 commented Jan 9, 2026

run vault_p0

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

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 Jan 9, 2026
@yujun777 yujun777 changed the title [fix](simplify range) fix merge compound value error reference [fix](simplify range) fix merge compound value with different references Jan 9, 2026
@yujun777 yujun777 changed the title [fix](simplify range) fix merge compound value with different references [fix](simplify range) no merge compound value with different references Jan 9, 2026
@yujun777
Copy link
Contributor Author

yujun777 commented Jan 9, 2026

run nonConcurrent

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 93.33% (14/15) 🎉
Increment coverage report
Complete coverage report

@morrySnow morrySnow merged commit 8c65fdc into apache:master Jan 9, 2026
32 of 33 checks passed
yujun777 added a commit to yujun777/doris that referenced this pull request Jan 9, 2026
…es (apache#59671)

simplify range have exception:

mysql >  explain select pk from table_0_500_undef_partitions2_keys3_properties4_distributed_by5 where  not ( date_sub(col_date_undef_signed, interval 1 day) > '2010-03-21' or null ) or lower(col_varchar_20__undef_signed) between null and 'e';
(1105, "errCode = 2, detailMessage = Cannot compare two values with different data types: 2010-03-22 (DATEV2) vs 'e' (VARCHAR(1))")

PR apache#57537  introduce  merging compound value with other value desc.

when merge value desc, it will merge values with the same reference.

but for compound value,  its reference have other meaning:
1) a < 1 or a > 10,  this is a compound value,  its reference is a;
2) a < 1 or b > 10, this is a compound value, its reference is 'a < 1 or
b > 10'.

then for expression `TA > 1 and FALSE or FALSE and SB > 'abc''`, for the
operator OR, it will have two compound values:
a. C1 = CompoundValue(referece = getCompoundExpression(TA > 1 and FALSE)
= FALSE, source values={TA > 1, FALSE})
b. C2 = CompoundValue(reference = getCompoundExpression(FALSE and SB >
'abc') = FALSE, source values={FALSE, SB > 'abc'})

because the function getCompoundExpression will fold constant, then C1
andC2's referece will be 'FALSE', and since C1 and C2's reference
equals, then will try merge C1 and C2, then will check merge ' > 1' and
' > abc' will cause the above exception.

to fix this, for a compound value if its source values different
reference (like a < 1 or b > 10), then don't merge it with other values
descs.
yujun777 added a commit to yujun777/doris that referenced this pull request Jan 9, 2026
…es (apache#59671)

simplify range have exception:

mysql >  explain select pk from table_0_500_undef_partitions2_keys3_properties4_distributed_by5 where  not ( date_sub(col_date_undef_signed, interval 1 day) > '2010-03-21' or null ) or lower(col_varchar_20__undef_signed) between null and 'e';
(1105, "errCode = 2, detailMessage = Cannot compare two values with different data types: 2010-03-22 (DATEV2) vs 'e' (VARCHAR(1))")

PR apache#57537  introduce  merging compound value with other value desc.

when merge value desc, it will merge values with the same reference.

but for compound value,  its reference have other meaning:
1) a < 1 or a > 10,  this is a compound value,  its reference is a;
2) a < 1 or b > 10, this is a compound value, its reference is 'a < 1 or
b > 10'.

then for expression `TA > 1 and FALSE or FALSE and SB > 'abc''`, for the
operator OR, it will have two compound values:
a. C1 = CompoundValue(referece = getCompoundExpression(TA > 1 and FALSE)
= FALSE, source values={TA > 1, FALSE})
b. C2 = CompoundValue(reference = getCompoundExpression(FALSE and SB >
'abc') = FALSE, source values={FALSE, SB > 'abc'})

because the function getCompoundExpression will fold constant, then C1
andC2's referece will be 'FALSE', and since C1 and C2's reference
equals, then will try merge C1 and C2, then will check merge ' > 1' and
' > abc' will cause the above exception.

to fix this, for a compound value if its source values different
reference (like a < 1 or b > 10), then don't merge it with other values
descs.
yujun777 added a commit to yujun777/doris that referenced this pull request Jan 12, 2026
…es (apache#59671)

simplify range have exception:

mysql >  explain select pk from table_0_500_undef_partitions2_keys3_properties4_distributed_by5 where  not ( date_sub(col_date_undef_signed, interval 1 day) > '2010-03-21' or null ) or lower(col_varchar_20__undef_signed) between null and 'e';
(1105, "errCode = 2, detailMessage = Cannot compare two values with different data types: 2010-03-22 (DATEV2) vs 'e' (VARCHAR(1))")

PR apache#57537  introduce  merging compound value with other value desc.

when merge value desc, it will merge values with the same reference.

but for compound value,  its reference have other meaning:
1) a < 1 or a > 10,  this is a compound value,  its reference is a;
2) a < 1 or b > 10, this is a compound value, its reference is 'a < 1 or
b > 10'.

then for expression `TA > 1 and FALSE or FALSE and SB > 'abc''`, for the
operator OR, it will have two compound values:
a. C1 = CompoundValue(referece = getCompoundExpression(TA > 1 and FALSE)
= FALSE, source values={TA > 1, FALSE})
b. C2 = CompoundValue(reference = getCompoundExpression(FALSE and SB >
'abc') = FALSE, source values={FALSE, SB > 'abc'})

because the function getCompoundExpression will fold constant, then C1
andC2's referece will be 'FALSE', and since C1 and C2's reference
equals, then will try merge C1 and C2, then will check merge ' > 1' and
' > abc' will cause the above exception.

to fix this, for a compound value if its source values different
reference (like a < 1 or b > 10), then don't merge it with other values
descs.
zzzxl1993 pushed a commit to zzzxl1993/doris that referenced this pull request Jan 13, 2026
…es (apache#59671)

simplify range have exception:

mysql >  explain select pk from table_0_500_undef_partitions2_keys3_properties4_distributed_by5 where  not ( date_sub(col_date_undef_signed, interval 1 day) > '2010-03-21' or null ) or lower(col_varchar_20__undef_signed) between null and 'e';
(1105, "errCode = 2, detailMessage = Cannot compare two values with different data types: 2010-03-22 (DATEV2) vs 'e' (VARCHAR(1))")

PR apache#57537  introduce  merging compound value with other value desc.

when merge value desc, it will merge values with the same reference.

but for compound value,  its reference have other meaning:
1) a < 1 or a > 10,  this is a compound value,  its reference is a;
2) a < 1 or b > 10, this is a compound value, its reference is 'a < 1 or
b > 10'.

then for expression `TA > 1 and FALSE or FALSE and SB > 'abc''`, for the
operator OR, it will have two compound values:
a. C1 = CompoundValue(referece = getCompoundExpression(TA > 1 and FALSE)
= FALSE, source values={TA > 1, FALSE})
b. C2 = CompoundValue(reference = getCompoundExpression(FALSE and SB >
'abc') = FALSE, source values={FALSE, SB > 'abc'})

because the function getCompoundExpression will fold constant, then C1
andC2's referece will be 'FALSE', and since C1 and C2's reference
equals, then will try merge C1 and C2, then will check merge ' > 1' and
' > abc' will cause the above exception.

to fix this, for a compound value if its source values different
reference (like a < 1 or b > 10), then don't merge it with other values
descs.
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. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants