Skip to content

Conversation

@924060929
Copy link
Contributor

@924060929 924060929 commented Oct 30, 2025

What problem does this PR solve?

Support dereference expression for map/struct/variant

MySQL root@127.0.0.1:rqg> select
                       ->   named_struct('c', named_struct('c', 100)).c.c,
                       ->   map('a', 10, 'b', 20).a,
                       ->   map('a', 10, 'b', 20).b,
                       ->   cast('{"a":{"b":300}}' as variant).a.b;
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| named_struct('c', named_struct('c', 100)).c.c | map('a', 10, 'b', 20).a | map('a', 10, 'b', 20).b | cast('{"a":{"b":300}}' as variant).a.b |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| 100                                           | 10                      | 20                      | 300                                    |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+

the slot name parts binding priority:

  1. try to bind catalog, if binding failed, jump to 2
  2. try to bind database, if binding failed, jump to 3
  3. try to bind table, if binding failed, jump to 4
  4. try to bind column

for example, a.a.a.a.a
first try to bind: catalog=a, database=a, table=a, column=a, sub fields=a
second try to bind: catalog=<current catalog>, database=a, table=a, column=a, sub fields=a.a
third try to bind: catalog=<current catalog>, database=<current database>, table=a, column=a, sub fields=a.a.a
4th try to bind: catalog=<current catalog>, database=<current database>, table=<underscore table>, column=a, sub fields=a.a.a.a

  • 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 30, 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?

@924060929
Copy link
Contributor Author

run buildall

1 similar comment
@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

query1	0.07	0.06	0.06
query2	0.10	0.06	0.06
query3	0.27	0.09	0.10
query4	1.61	0.14	0.12
query5	0.30	0.28	0.27
query6	1.18	0.70	0.68
query7	0.04	0.04	0.03
query8	0.07	0.06	0.05
query9	0.67	0.57	0.56
query10	0.63	0.64	0.63
query11	0.19	0.13	0.13
query12	0.18	0.13	0.14
query13	0.65	0.64	0.61
query14	1.07	1.03	1.04
query15	0.91	0.89	0.90
query16	0.43	0.42	0.44
query17	1.08	1.21	1.11
query18	0.24	0.23	0.22
query19	2.07	1.93	2.00
query20	0.02	0.01	0.01
query21	15.39	0.20	0.15
query22	5.14	0.07	0.05
query23	15.66	0.29	0.12
query24	2.56	1.41	0.32
query25	0.08	0.07	0.06
query26	0.16	0.16	0.16
query27	0.08	0.07	0.06
query28	4.44	1.20	0.97
query29	12.59	4.66	3.82
query30	0.30	0.16	0.13
query31	2.85	0.67	0.43
query32	3.24	0.59	0.49
query33	3.28	3.07	3.09
query34	15.79	5.31	4.65
query35	4.62	4.70	4.69
query36	0.70	0.53	0.52
query37	0.11	0.08	0.07
query38	0.07	0.05	0.04
query39	0.04	0.04	0.04
query40	0.19	0.16	0.15
query41	0.09	0.03	0.04
query42	0.04	0.03	0.04
query43	0.04	0.04	0.04
Total cold run time: 99.24 s
Total hot run time: 29.12 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 56.56% (69/122) 🎉
Increment coverage report
Complete coverage report

@924060929 924060929 changed the title [feature](nereids) Support dereference expression [feature](nereids) Support some syntax sugar Oct 31, 2025
@924060929
Copy link
Contributor Author

run buildall

@924060929 924060929 changed the title [feature](nereids) Support some syntax sugar [feature](nereids) Support dereference expression Oct 31, 2025
@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

query1	0.06	0.05	0.04
query2	0.08	0.04	0.05
query3	0.25	0.09	0.08
query4	1.60	0.12	0.12
query5	0.28	0.28	0.25
query6	1.18	0.66	0.64
query7	0.03	0.03	0.03
query8	0.05	0.04	0.05
query9	0.62	0.53	0.54
query10	0.58	0.58	0.58
query11	0.16	0.11	0.12
query12	0.16	0.12	0.13
query13	0.61	0.60	0.60
query14	1.01	0.99	1.03
query15	0.85	0.83	0.84
query16	0.39	0.39	0.39
query17	1.01	1.02	1.06
query18	0.21	0.22	0.21
query19	1.89	1.81	1.82
query20	0.02	0.01	0.02
query21	15.44	0.21	0.13
query22	5.01	0.07	0.05
query23	15.65	0.27	0.10
query24	2.62	0.52	0.40
query25	0.08	0.06	0.07
query26	0.13	0.14	0.13
query27	0.08	0.06	0.05
query28	4.09	1.17	0.94
query29	12.63	4.01	3.30
query30	0.28	0.13	0.12
query31	2.83	0.59	0.39
query32	3.23	0.55	0.47
query33	3.09	3.10	3.05
query34	15.90	5.18	4.67
query35	4.58	4.53	4.59
query36	0.68	0.51	0.48
query37	0.11	0.07	0.07
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.14	0.14
query41	0.08	0.03	0.04
query42	0.04	0.04	0.03
query43	0.04	0.04	0.03
Total cold run time: 97.92 s
Total hot run time: 27.68 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 58.27% (74/127) 🎉
Increment coverage report
Complete coverage report

2 similar comments
@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 58.27% (74/127) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 58.27% (74/127) 🎉
Increment coverage report
Complete coverage report

@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17651	5103	4885	4885
q2	2002	345	205	205
q3	10250	1272	726	726
q4	10230	891	354	354
q5	7535	2487	2200	2200
q6	186	171	142	142
q7	952	785	631	631
q8	9348	1302	954	954
q9	6950	5291	5286	5286
q10	6852	2241	1810	1810
q11	507	313	283	283
q12	335	366	221	221
q13	17843	3656	3014	3014
q14	237	249	220	220
q15	622	536	557	536
q16	909	865	821	821
q17	574	800	486	486
q18	7664	7271	7243	7243
q19	1274	954	578	578
q20	362	348	231	231
q21	3646	3173	2275	2275
q22	1018	972	956	956
Total cold run time: 106947 ms
Total hot run time: 34057 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4976	4903	4876	4876
q2	329	389	308	308
q3	2129	2619	2292	2292
q4	1319	1723	1290	1290
q5	4178	4349	4457	4349
q6	220	181	136	136
q7	2119	1946	1821	1821
q8	2674	2499	2503	2499
q9	7376	7473	7320	7320
q10	3088	3261	2819	2819
q11	594	529	485	485
q12	708	732	596	596
q13	3581	4014	3293	3293
q14	304	321	272	272
q15	564	511	500	500
q16	883	947	879	879
q17	1133	1470	1464	1464
q18	7872	7529	7551	7529
q19	768	734	735	734
q20	1866	1960	1815	1815
q21	4602	4410	4225	4225
q22	1102	994	980	980
Total cold run time: 52385 ms
Total hot run time: 50482 ms

@doris-robot
Copy link

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

query1	1038	403	428	403
query2	6557	1563	1547	1547
query3	6754	228	220	220
query4	25207	23283	22990	22990
query5	5281	656	464	464
query6	328	243	225	225
query7	4642	511	306	306
query8	312	247	233	233
query9	8731	2568	2593	2568
query10	553	358	298	298
query11	15075	15065	14934	14934
query12	192	122	117	117
query13	1685	554	448	448
query14	9329	5545	5449	5449
query15	211	200	185	185
query16	7689	689	520	520
query17	1207	759	630	630
query18	2042	448	336	336
query19	209	210	179	179
query20	135	124	125	124
query21	215	135	115	115
query22	3883	4043	3935	3935
query23	32660	31838	31894	31838
query24	8566	2438	2396	2396
query25	633	563	462	462
query26	1254	323	169	169
query27	2664	483	342	342
query28	4317	2129	2109	2109
query29	771	609	489	489
query30	304	237	208	208
query31	806	702	615	615
query32	85	73	73	73
query33	579	374	317	317
query34	808	857	538	538
query35	810	825	744	744
query36	858	928	831	831
query37	118	106	92	92
query38	3786	3810	3724	3724
query39	1446	1414	1420	1414
query40	226	131	120	120
query41	68	61	61	61
query42	123	113	111	111
query43	441	446	419	419
query44	1269	766	747	747
query45	194	192	185	185
query46	856	983	634	634
query47	1690	1727	1652	1652
query48	406	408	321	321
query49	770	516	407	407
query50	649	684	418	418
query51	4040	3891	3972	3891
query52	111	108	104	104
query53	244	264	196	196
query54	296	305	277	277
query55	99	94	94	94
query56	339	329	315	315
query57	1122	1151	1099	1099
query58	291	263	274	263
query59	2332	2335	2301	2301
query60	342	346	335	335
query61	158	159	160	159
query62	774	721	672	672
query63	225	186	196	186
query64	4493	1189	889	889
query65	4034	3970	3975	3970
query66	1060	446	330	330
query67	15144	14871	14839	14839
query68	8322	928	618	618
query69	520	343	311	311
query70	1089	1044	979	979
query71	445	335	309	309
query72	6049	4849	4787	4787
query73	665	590	343	343
query74	8464	8759	8690	8690
query75	3210	3066	2559	2559
query76	3405	1120	735	735
query77	687	400	308	308
query78	9407	9722	8923	8923
query79	1496	801	608	608
query80	663	595	507	507
query81	515	267	255	255
query82	233	139	109	109
query83	266	261	251	251
query84	263	119	104	104
query85	883	467	437	437
query86	361	321	302	302
query87	4003	4042	3996	3996
query88	2850	2300	2317	2300
query89	390	342	307	307
query90	1937	225	221	221
query91	196	164	142	142
query92	83	72	67	67
query93	1196	976	661	661
query94	722	435	330	330
query95	493	407	401	401
query96	513	532	291	291
query97	2583	2692	2583	2583
query98	236	217	218	217
query99	1314	1413	1267	1267
Total cold run time: 266995 ms
Total hot run time: 181500 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.05
query2	0.10	0.05	0.05
query3	0.26	0.09	0.09
query4	1.61	0.12	0.11
query5	0.29	0.26	0.25
query6	1.17	0.64	0.63
query7	0.03	0.02	0.02
query8	0.05	0.04	0.05
query9	0.57	0.51	0.50
query10	0.55	0.55	0.55
query11	0.16	0.10	0.11
query12	0.15	0.12	0.11
query13	0.63	0.60	0.60
query14	0.99	0.97	0.99
query15	0.83	0.81	0.80
query16	0.40	0.42	0.41
query17	0.96	1.02	0.98
query18	0.24	0.21	0.21
query19	1.84	1.86	1.79
query20	0.02	0.02	0.01
query21	15.44	0.26	0.14
query22	4.83	0.05	0.04
query23	16.06	0.27	0.10
query24	1.76	0.28	0.93
query25	0.11	0.06	0.17
query26	0.13	0.14	0.12
query27	0.07	0.05	0.06
query28	5.25	1.20	1.02
query29	12.64	3.92	3.24
query30	0.28	0.14	0.11
query31	2.82	0.61	0.40
query32	3.23	0.54	0.46
query33	3.08	3.06	3.06
query34	16.89	5.17	4.57
query35	4.59	4.59	4.59
query36	0.66	0.49	0.48
query37	0.10	0.06	0.06
query38	0.07	0.04	0.04
query39	0.04	0.02	0.02
query40	0.17	0.15	0.14
query41	0.09	0.03	0.03
query42	0.04	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 99.3 s
Total hot run time: 27.33 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 58.65% (61/104) 🎉
Increment coverage report
Complete coverage report

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Nov 28, 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.

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 58.65% (61/104) 🎉
Increment coverage report
Complete coverage report

@924060929 924060929 merged commit ac92fd4 into apache:master Nov 28, 2025
29 of 31 checks passed
@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 58.65% (61/104) 🎉
Increment coverage report
Complete coverage report

924060929 added a commit to 924060929/incubator-doris that referenced this pull request Dec 1, 2025
Support dereference expression for map/struct/variant

```sql
MySQL root@127.0.0.1:rqg> select
                       ->   named_struct('c', named_struct('c', 100)).c.c,
                       ->   map('a', 10, 'b', 20).a,
                       ->   map('a', 10, 'b', 20).b,
                       ->   cast('{"a":{"b":300}}' as variant).a.b;
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| named_struct('c', named_struct('c', 100)).c.c | map('a', 10, 'b', 20).a | map('a', 10, 'b', 20).b | cast('{"a":{"b":300}}' as variant).a.b |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| 100                                           | 10                      | 20                      | 300                                    |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
```

<b>the slot name parts binding priority:</b>
1. try to bind catalog, if binding failed, jump to 2
2. try to bind database, if binding failed, jump to 3
3. try to bind table, if binding failed, jump to 4
4. try to bind column

for example, `a.a.a.a.a`
first try to bind: catalog=a, database=a, table=a, column=a, sub
fields=a
second try to bind: catalog=&lt;current catalog&gt;, database=a,
table=a, column=a, sub fields=a.a
third try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=a, column=a, sub fields=a.a.a
4th try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=&lt;underscore table&gt;, column=a, sub
fields=a.a.a.a

(cherry picked from commit ac92fd4)
924060929 added a commit to 924060929/incubator-doris that referenced this pull request Dec 1, 2025
Support dereference expression for map/struct/variant

```sql
MySQL root@127.0.0.1:rqg> select
                       ->   named_struct('c', named_struct('c', 100)).c.c,
                       ->   map('a', 10, 'b', 20).a,
                       ->   map('a', 10, 'b', 20).b,
                       ->   cast('{"a":{"b":300}}' as variant).a.b;
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| named_struct('c', named_struct('c', 100)).c.c | map('a', 10, 'b', 20).a | map('a', 10, 'b', 20).b | cast('{"a":{"b":300}}' as variant).a.b |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| 100                                           | 10                      | 20                      | 300                                    |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
```

<b>the slot name parts binding priority:</b>
1. try to bind catalog, if binding failed, jump to 2
2. try to bind database, if binding failed, jump to 3
3. try to bind table, if binding failed, jump to 4
4. try to bind column

for example, `a.a.a.a.a`
first try to bind: catalog=a, database=a, table=a, column=a, sub
fields=a
second try to bind: catalog=&lt;current catalog&gt;, database=a,
table=a, column=a, sub fields=a.a
third try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=a, column=a, sub fields=a.a.a
4th try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=&lt;underscore table&gt;, column=a, sub
fields=a.a.a.a

(cherry picked from commit ac92fd4)
924060929 added a commit that referenced this pull request Dec 3, 2025
fix can not prune dereference expression, introduced by #57532
nagisa-kunhah pushed a commit to nagisa-kunhah/doris that referenced this pull request Dec 14, 2025
Support dereference expression for map/struct/variant

```sql
MySQL root@127.0.0.1:rqg> select
                       ->   named_struct('c', named_struct('c', 100)).c.c,
                       ->   map('a', 10, 'b', 20).a,
                       ->   map('a', 10, 'b', 20).b,
                       ->   cast('{"a":{"b":300}}' as variant).a.b;
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| named_struct('c', named_struct('c', 100)).c.c | map('a', 10, 'b', 20).a | map('a', 10, 'b', 20).b | cast('{"a":{"b":300}}' as variant).a.b |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| 100                                           | 10                      | 20                      | 300                                    |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
```


<b>the slot name parts binding priority:</b>
1. try to bind catalog, if binding failed, jump to 2
2. try to bind database, if binding failed, jump to 3
3. try to bind table, if binding failed, jump to 4
4. try to bind column


for example, `a.a.a.a.a`
first try to bind: catalog=a, database=a, table=a, column=a, sub
fields=a
second try to bind: catalog=&lt;current catalog&gt;, database=a,
table=a, column=a, sub fields=a.a
third try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=a, column=a, sub fields=a.a.a
4th try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=&lt;underscore table&gt;, column=a, sub
fields=a.a.a.a
nagisa-kunhah pushed a commit to nagisa-kunhah/doris that referenced this pull request Dec 14, 2025
fix can not prune dereference expression, introduced by apache#57532
924060929 added a commit that referenced this pull request Dec 23, 2025
fix can not prune dereference expression, introduced by #57532

(cherry picked from commit 2b23693)
924060929 added a commit that referenced this pull request Dec 23, 2025
fix can not prune dereference expression, introduced by #57532

(cherry picked from commit 2b23693)
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.4-merged dev/4.0.2-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants