Skip to content

Conversation

@uchenily
Copy link
Contributor

@uchenily uchenily commented Nov 27, 2025

What problem does this PR solve?

This PR improves compatibility with MySQL arithmetic expression syntax, allow user use % and MOD to represent modular semantics.

Note that the MOD is a non-reserved keyword, can be used in arithmetic expressions, MOD function name or to represent aliases in as statements.

before:

SELECT 10 MOD 3 as mod;
ERROR 1105 (HY000): errCode = 2, detailMessage =
mismatched input '3' expecting {<EOF>, ';'}(line 1, pos 19)

after:

mysql> SELECT 10 MOD 3 as mod;
+------+
| mod  |
+------+
|    1 |
+------+

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?

@uchenily
Copy link
Contributor Author

run buildall

1 similar comment
@uchenily
Copy link
Contributor Author

run buildall

@uchenily uchenily changed the title [feat](synax) compatiable with mysql MOD syntax [improve](synax) compatiable with mysql MOD syntax Nov 27, 2025
@uchenily
Copy link
Contributor Author

run buildall

@yiguolei yiguolei added usercase Important user case type label dev/4.0.x labels Nov 27, 2025
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17608	5027	4895	4895
q2	2051	310	201	201
q3	10233	1264	713	713
q4	10237	912	381	381
q5	7494	2324	2345	2324
q6	189	173	139	139
q7	930	789	655	655
q8	9351	1437	1119	1119
q9	7134	5329	5379	5329
q10	6888	2241	1826	1826
q11	528	305	283	283
q12	351	368	231	231
q13	17788	3689	3089	3089
q14	246	238	210	210
q15	586	530	507	507
q16	1005	1022	960	960
q17	594	859	361	361
q18	7358	7217	7138	7138
q19	1238	945	552	552
q20	363	327	232	232
q21	4085	3293	2363	2363
q22	1035	1000	959	959
Total cold run time: 107292 ms
Total hot run time: 34467 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5048	5114	4957	4957
q2	327	414	309	309
q3	2201	2715	2296	2296
q4	1405	1810	1388	1388
q5	4268	4574	4489	4489
q6	217	175	136	136
q7	2052	1981	1995	1981
q8	2647	2727	2569	2569
q9	7483	7458	7498	7458
q10	3027	3316	2855	2855
q11	579	527	494	494
q12	684	783	631	631
q13	3601	3962	3572	3572
q14	279	318	276	276
q15	561	504	500	500
q16	1053	1133	1069	1069
q17	1136	1629	1439	1439
q18	8081	7608	7569	7569
q19	792	796	888	796
q20	2026	2127	1931	1931
q21	4979	4374	4378	4374
q22	1107	1039	1029	1029
Total cold run time: 53553 ms
Total hot run time: 52118 ms

@doris-robot
Copy link

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

query1	1062	426	404	404
query2	6601	1614	1571	1571
query3	6759	217	216	216
query4	26379	23435	22844	22844
query5	4376	636	479	479
query6	332	235	210	210
query7	4645	495	307	307
query8	313	248	254	248
query9	8724	2537	2575	2537
query10	491	348	304	304
query11	15013	14913	14625	14625
query12	177	120	114	114
query13	1680	578	449	449
query14	10118	8981	8887	8887
query15	223	197	187	187
query16	7373	679	535	535
query17	1301	753	630	630
query18	1989	423	326	326
query19	213	205	176	176
query20	128	122	120	120
query21	215	132	114	114
query22	3896	4128	3922	3922
query23	33088	31880	32224	31880
query24	8452	2377	2413	2377
query25	588	516	483	483
query26	1237	275	164	164
query27	2761	491	348	348
query28	4377	2139	2115	2115
query29	826	611	485	485
query30	309	239	214	214
query31	838	730	654	654
query32	85	74	71	71
query33	584	367	323	323
query34	800	873	540	540
query35	798	807	736	736
query36	898	973	874	874
query37	122	115	85	85
query38	3419	3366	3327	3327
query39	1493	1425	1413	1413
query40	228	131	124	124
query41	66	66	62	62
query42	125	120	112	112
query43	462	461	437	437
query44	1222	765	749	749
query45	198	189	191	189
query46	884	981	634	634
query47	1723	1696	1644	1644
query48	385	423	331	331
query49	797	496	403	403
query50	642	675	427	427
query51	3985	3910	3866	3866
query52	116	112	108	108
query53	240	260	192	192
query54	313	294	275	275
query55	102	93	99	93
query56	332	320	305	305
query57	1162	1198	1102	1102
query58	286	276	279	276
query59	2383	2630	2462	2462
query60	361	338	343	338
query61	201	188	193	188
query62	796	693	650	650
query63	230	198	198	198
query64	4681	1320	1017	1017
query65	4032	3933	3992	3933
query66	1186	449	348	348
query67	15255	14941	14952	14941
query68	8282	903	635	635
query69	522	346	322	322
query70	1294	1258	1186	1186
query71	425	350	318	318
query72	5974	4931	4936	4931
query73	645	613	351	351
query74	8973	8721	8611	8611
query75	3471	3356	2849	2849
query76	3359	1114	705	705
query77	666	404	319	319
query78	9364	9687	8966	8966
query79	2304	796	595	595
query80	617	575	486	486
query81	528	270	234	234
query82	457	159	134	134
query83	268	263	248	248
query84	263	110	103	103
query85	917	480	436	436
query86	384	309	299	299
query87	3547	3544	3333	3333
query88	3764	2284	2215	2215
query89	392	334	284	284
query90	1955	214	214	214
query91	172	167	146	146
query92	84	71	60	60
query93	1884	984	658	658
query94	757	446	335	335
query95	503	409	399	399
query96	491	568	287	287
query97	2952	2952	2873	2873
query98	241	222	220	220
query99	1702	1426	1256	1256
Total cold run time: 272233 ms
Total hot run time: 184706 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.04
query2	0.10	0.05	0.05
query3	0.25	0.09	0.08
query4	1.61	0.11	0.12
query5	0.28	0.26	0.26
query6	1.20	0.68	0.68
query7	0.04	0.03	0.02
query8	0.05	0.04	0.04
query9	0.60	0.52	0.52
query10	0.58	0.56	0.58
query11	0.16	0.11	0.12
query12	0.15	0.12	0.12
query13	0.64	0.63	0.60
query14	1.04	1.01	1.02
query15	0.88	0.87	0.87
query16	0.40	0.40	0.42
query17	1.03	1.03	1.07
query18	0.22	0.21	0.20
query19	1.93	1.78	1.89
query20	0.02	0.01	0.02
query21	15.42	0.18	0.14
query22	5.10	0.07	0.05
query23	15.66	0.25	0.10
query24	2.94	0.57	0.58
query25	0.08	0.06	0.06
query26	0.15	0.14	0.13
query27	0.08	0.06	0.05
query28	4.77	1.18	0.93
query29	12.60	3.92	3.22
query30	0.29	0.14	0.12
query31	2.83	0.64	0.41
query32	3.23	0.59	0.51
query33	3.06	3.02	3.14
query34	15.83	5.30	4.56
query35	4.59	4.64	4.61
query36	0.69	0.51	0.50
query37	0.11	0.07	0.06
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.14	0.14
query41	0.09	0.03	0.04
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 99.13 s
Total hot run time: 27.84 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (1/1) 🎉
Increment coverage report
Complete coverage report

@uchenily
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/1) 🎉
Increment coverage report
Complete coverage report

@uchenily uchenily changed the title [improve](synax) compatiable with mysql MOD syntax [improve](syntax) compatiable with mysql MOD syntax Nov 27, 2025
@uchenily
Copy link
Contributor Author

run performance

@uchenily
Copy link
Contributor Author

run p0

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17628	5136	4971	4971
q2	2041	323	203	203
q3	10266	1360	764	764
q4	10231	922	381	381
q5	7494	2517	2317	2317
q6	180	174	141	141
q7	975	791	659	659
q8	9357	1431	1141	1141
q9	7283	5419	5395	5395
q10	6909	2243	1801	1801
q11	529	311	286	286
q12	375	379	228	228
q13	17787	3649	3075	3075
q14	230	231	213	213
q15	589	514	513	513
q16	1050	1026	973	973
q17	576	743	514	514
q18	7606	7146	7174	7146
q19	1088	975	580	580
q20	340	341	230	230
q21	4021	3250	2358	2358
q22	1029	987	970	970
Total cold run time: 107584 ms
Total hot run time: 34859 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4955	4965	4907	4907
q2	346	407	334	334
q3	2123	2798	2286	2286
q4	1321	1729	1287	1287
q5	4197	4649	4606	4606
q6	229	179	134	134
q7	2087	2014	1885	1885
q8	2707	2579	2500	2500
q9	7618	7387	7526	7387
q10	3055	3260	2895	2895
q11	645	593	530	530
q12	679	749	613	613
q13	3453	3965	3397	3397
q14	321	296	288	288
q15	560	497	511	497
q16	1096	1174	1091	1091
q17	1187	1420	1453	1420
q18	7859	7715	7619	7619
q19	859	830	858	830
q20	2030	2050	1982	1982
q21	4926	4560	4221	4221
q22	1080	1018	976	976
Total cold run time: 53333 ms
Total hot run time: 51685 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 184094 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 52bb661680a2743b3de3ecf599a27c7e8770e358, data reload: false

query1	1034	402	397	397
query2	6618	1597	1542	1542
query3	6762	230	224	224
query4	25443	23130	22760	22760
query5	4434	627	471	471
query6	336	253	214	214
query7	4657	508	298	298
query8	317	270	240	240
query9	8696	2586	2571	2571
query10	532	354	300	300
query11	15278	15026	14862	14862
query12	179	120	117	117
query13	1708	563	464	464
query14	10092	8744	8826	8744
query15	213	207	189	189
query16	7177	716	530	530
query17	1011	788	652	652
query18	2012	442	337	337
query19	218	204	185	185
query20	137	127	122	122
query21	223	140	116	116
query22	3781	3902	3799	3799
query23	32757	31952	31810	31810
query24	8620	2459	2431	2431
query25	671	559	489	489
query26	1255	276	175	175
query27	2762	499	357	357
query28	4407	2175	2149	2149
query29	871	641	533	533
query30	312	243	214	214
query31	839	730	632	632
query32	85	78	73	73
query33	610	394	347	347
query34	818	873	549	549
query35	806	893	750	750
query36	910	920	830	830
query37	122	113	88	88
query38	3336	3376	3277	3277
query39	1479	1434	1399	1399
query40	231	142	117	117
query41	68	63	64	63
query42	133	112	111	111
query43	454	452	424	424
query44	1282	765	755	755
query45	196	190	182	182
query46	875	999	643	643
query47	1724	1751	1684	1684
query48	397	422	335	335
query49	769	501	411	411
query50	655	677	420	420
query51	3847	3973	3875	3875
query52	112	115	110	110
query53	237	258	192	192
query54	316	313	282	282
query55	100	94	97	94
query56	341	337	341	337
query57	1158	1165	1076	1076
query58	296	277	270	270
query59	2313	2481	2298	2298
query60	407	362	335	335
query61	193	168	169	168
query62	783	700	659	659
query63	231	195	190	190
query64	4618	1219	892	892
query65	4072	3966	3950	3950
query66	1204	443	336	336
query67	15408	14980	14754	14754
query68	8411	959	635	635
query69	521	346	302	302
query70	1283	1203	1239	1203
query71	497	337	317	317
query72	5873	4904	4840	4840
query73	694	574	347	347
query74	8826	8723	8531	8531
query75	3905	3334	2829	2829
query76	3688	1133	706	706
query77	827	411	316	316
query78	9545	9626	8847	8847
query79	1777	836	612	612
query80	641	586	516	516
query81	492	270	244	244
query82	459	157	132	132
query83	281	271	248	248
query84	303	112	98	98
query85	944	489	454	454
query86	344	295	286	286
query87	3464	3606	3398	3398
query88	3298	2295	2283	2283
query89	391	340	296	296
query90	1975	228	219	219
query91	177	176	147	147
query92	86	71	66	66
query93	1106	997	653	653
query94	738	450	346	346
query95	519	418	408	408
query96	521	542	293	293
query97	2886	2992	2855	2855
query98	233	219	214	214
query99	1452	1376	1253	1253
Total cold run time: 270095 ms
Total hot run time: 184094 ms

@doris-robot
Copy link

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

query1	0.05	0.05	0.05
query2	0.10	0.05	0.05
query3	0.26	0.09	0.09
query4	1.60	0.12	0.12
query5	0.27	0.26	0.25
query6	1.19	0.64	0.63
query7	0.03	0.03	0.02
query8	0.06	0.04	0.04
query9	0.58	0.50	0.50
query10	0.56	0.56	0.55
query11	0.16	0.11	0.11
query12	0.16	0.12	0.11
query13	0.63	0.59	0.61
query14	0.98	0.98	0.98
query15	0.82	0.79	0.80
query16	0.40	0.39	0.43
query17	1.03	1.01	1.03
query18	0.25	0.21	0.22
query19	1.80	1.84	1.87
query20	0.02	0.01	0.01
query21	15.44	0.26	0.14
query22	4.75	0.05	0.04
query23	16.05	0.26	0.11
query24	0.95	0.48	0.18
query25	0.08	0.06	0.06
query26	0.14	0.12	0.13
query27	0.05	0.06	0.05
query28	3.57	1.25	1.02
query29	12.61	3.98	3.22
query30	0.28	0.14	0.12
query31	2.81	0.61	0.41
query32	3.23	0.54	0.46
query33	3.01	3.11	3.11
query34	16.90	5.20	4.48
query35	4.58	4.61	4.53
query36	0.66	0.50	0.48
query37	0.10	0.07	0.07
query38	0.08	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.15	0.13
query41	0.09	0.03	0.02
query42	0.04	0.03	0.02
query43	0.05	0.04	0.04
Total cold run time: 96.64 s
Total hot run time: 27.22 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (1/1) 🎉
Increment coverage report
Complete coverage report

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Nov 28, 2025
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit 774fc26 into apache:master Jan 7, 2026
30 of 31 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 7, 2026
### What problem does this PR solve?

This PR improves compatibility with MySQL arithmetic expression syntax,
allow user use `%` and `MOD` to represent modular semantics.

Note that the `MOD` is a non-reserved keyword, can be used in arithmetic
expressions, MOD function name or to represent aliases in as statements.

before:

```sql
SELECT 10 MOD 3 as mod;
ERROR 1105 (HY000): errCode = 2, detailMessage =
mismatched input '3' expecting {<EOF>, ';'}(line 1, pos 19)
```

after:

```sql
mysql> SELECT 10 MOD 3 as mod;
+------+
| mod  |
+------+
|    1 |
+------+
```

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [x] 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 <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
yiguolei pushed a commit that referenced this pull request Jan 8, 2026
#59637)

Cherry-picked from #58432

Co-authored-by: ivin <uchenily@qq.com>
zzzxl1993 pushed a commit to zzzxl1993/doris that referenced this pull request Jan 13, 2026
### What problem does this PR solve?

This PR improves compatibility with MySQL arithmetic expression syntax,
allow user use `%` and `MOD` to represent modular semantics.

Note that the `MOD` is a non-reserved keyword, can be used in arithmetic
expressions, MOD function name or to represent aliases in as statements.

before:

```sql
SELECT 10 MOD 3 as mod;
ERROR 1105 (HY000): errCode = 2, detailMessage =
mismatched input '3' expecting {<EOF>, ';'}(line 1, pos 19)
```

after:

```sql
mysql> SELECT 10 MOD 3 as mod;
+------+
| mod  |
+------+
|    1 |
+------+
```

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [x] 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 <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
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.3-merged reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants