Skip to content

Conversation

@mrhhsg
Copy link
Member

@mrhhsg mrhhsg commented Oct 16, 2025

What problem does this PR solve?

Since the EXPLODE function supports multiple arguments, its return value is defined as a STRUCT type. Even when it has only a single argument, it still returns a STRUCT.
Consider the following example:

SELECT * 
FROM (SELECT 1) t1 
LATERAL VIEW explode(array(struct('a', 1), struct('b', 2))) t2 AS c1, c2;
+------+------------------------+
| 1    | c1                     |
+------+------------------------+
|    1 | {"col1":"a", "col2":1} |
|    1 | {"col1":"b", "col2":2} |
+------+------------------------+

In this SQL statement, the return value of the EXPLODE function is a nested STRUCT (that is, the child column inside the struct is struct too).
As a result, the final output extracts the child column from the outer struct, but those child columns themselves are not correctly assigned to c1 and c2.

With this PR, the result will be like this:

+------+------+------+
| 1    | c1   | c2   |
+------+------+------+
|    1 | a    |    1 |
|    1 | b    |    2 |
+------+------+------+

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

@Thearas
Copy link
Contributor

Thearas commented Oct 16, 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?

@mrhhsg
Copy link
Member Author

mrhhsg commented Oct 16, 2025

run buildall

@mrhhsg
Copy link
Member Author

mrhhsg commented Oct 16, 2025

run buildall
/

@mrhhsg
Copy link
Member Author

mrhhsg commented Oct 16, 2025

run buildall

@doris-robot
Copy link

TPC-DS: Total hot run time: 189309 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 24ba63801e60a509d558c65269014995690e829f, data reload: false

query1	1085	440	414	414
query2	6556	1717	1706	1706
query3	6755	230	222	222
query4	26232	23732	23001	23001
query5	5632	627	484	484
query6	358	245	235	235
query7	4662	503	307	307
query8	316	284	259	259
query9	8724	2622	2544	2544
query10	551	340	286	286
query11	15603	15308	14902	14902
query12	200	123	112	112
query13	1673	559	426	426
query14	12567	9181	9199	9181
query15	253	195	175	175
query16	7776	652	509	509
query17	1571	761	598	598
query18	2688	496	341	341
query19	268	213	201	201
query20	154	140	133	133
query21	248	145	116	116
query22	4731	4654	4624	4624
query23	34927	33755	33540	33540
query24	8459	2467	2527	2467
query25	624	525	470	470
query26	1318	287	172	172
query27	3060	537	366	366
query28	4521	2329	2218	2218
query29	772	634	496	496
query30	293	238	216	216
query31	954	838	801	801
query32	87	76	75	75
query33	633	395	342	342
query34	839	874	529	529
query35	846	854	815	815
query36	994	1046	980	980
query37	124	104	86	86
query38	3506	3556	3458	3458
query39	1481	1394	1396	1394
query40	223	123	116	116
query41	64	58	57	57
query42	155	106	118	106
query43	487	508	461	461
query44	1319	821	808	808
query45	183	178	183	178
query46	840	998	638	638
query47	1764	1829	1710	1710
query48	392	413	328	328
query49	771	492	411	411
query50	644	698	407	407
query51	3923	3921	3915	3915
query52	104	107	99	99
query53	242	261	194	194
query54	599	579	529	529
query55	83	82	83	82
query56	320	326	302	302
query57	1175	1208	1114	1114
query58	290	277	291	277
query59	2574	2691	2571	2571
query60	364	350	349	349
query61	182	181	187	181
query62	810	730	664	664
query63	231	206	202	202
query64	4551	1138	836	836
query65	4110	3946	3965	3946
query66	1041	431	335	335
query67	15437	15128	15018	15018
query68	8055	938	585	585
query69	520	324	313	313
query70	1365	1319	1297	1297
query71	545	345	335	335
query72	5511	4809	4774	4774
query73	627	557	358	358
query74	8943	9245	8647	8647
query75	4108	3336	2870	2870
query76	3665	1161	757	757
query77	819	414	320	320
query78	9510	9844	8951	8951
query79	1992	827	603	603
query80	631	641	508	508
query81	497	284	226	226
query82	319	154	131	131
query83	261	268	252	252
query84	261	106	96	96
query85	870	457	409	409
query86	344	295	302	295
query87	3660	3697	3652	3652
query88	3487	2286	2208	2208
query89	466	321	299	299
query90	2026	219	219	219
query91	167	166	135	135
query92	87	67	65	65
query93	1136	974	648	648
query94	649	441	329	329
query95	408	336	320	320
query96	487	572	284	284
query97	2968	2980	2846	2846
query98	243	222	211	211
query99	1337	1415	1331	1331
Total cold run time: 280883 ms
Total hot run time: 189309 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.04
query2	0.09	0.05	0.06
query3	0.25	0.08	0.08
query4	1.61	0.11	0.12
query5	0.28	0.27	0.25
query6	1.19	0.65	0.65
query7	0.03	0.03	0.03
query8	0.06	0.04	0.05
query9	0.63	0.54	0.51
query10	0.57	0.57	0.57
query11	0.17	0.14	0.11
query12	0.16	0.12	0.12
query13	0.64	0.62	0.62
query14	1.02	1.04	1.02
query15	0.86	0.84	0.87
query16	0.41	0.40	0.39
query17	1.03	1.04	1.09
query18	0.21	0.20	0.19
query19	1.98	1.80	1.79
query20	0.02	0.02	0.02
query21	15.44	0.93	0.57
query22	0.75	1.33	0.62
query23	14.85	1.41	0.64
query24	6.87	1.01	0.93
query25	0.52	0.31	0.08
query26	0.61	0.16	0.15
query27	0.07	0.06	0.05
query28	9.71	1.38	0.91
query29	12.57	3.98	3.25
query30	0.28	0.14	0.11
query31	2.83	0.61	0.39
query32	3.25	0.56	0.49
query33	3.09	3.08	3.09
query34	16.05	5.48	4.91
query35	4.91	4.94	4.87
query36	0.69	0.52	0.49
query37	0.10	0.07	0.08
query38	0.07	0.05	0.05
query39	0.04	0.03	0.03
query40	0.19	0.16	0.15
query41	0.09	0.03	0.04
query42	0.04	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 104.34 s
Total hot run time: 30.4 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

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

@mrhhsg
Copy link
Member Author

mrhhsg commented Oct 16, 2025

run buildall

@doris-robot
Copy link

TPC-DS: Total hot run time: 190296 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 61de25e329d362e9d18a215414fb3089f2551bc4, data reload: false

query1	1076	419	407	407
query2	6565	1698	1725	1698
query3	6748	220	220	220
query4	25560	23446	23014	23014
query5	4643	672	499	499
query6	329	240	215	215
query7	4651	492	296	296
query8	296	251	253	251
query9	8716	2567	2547	2547
query10	464	347	306	306
query11	15659	15132	15344	15132
query12	186	121	113	113
query13	1682	552	424	424
query14	12046	9177	9169	9169
query15	215	194	173	173
query16	7666	709	531	531
query17	1382	747	675	675
query18	2041	416	318	318
query19	210	247	192	192
query20	141	137	141	137
query21	215	139	122	122
query22	4937	4893	4577	4577
query23	34795	34141	33866	33866
query24	8737	2496	2531	2496
query25	635	589	473	473
query26	1271	294	166	166
query27	2799	522	362	362
query28	4498	2240	2203	2203
query29	820	642	499	499
query30	297	252	221	221
query31	1012	859	764	764
query32	90	76	71	71
query33	615	390	355	355
query34	810	882	540	540
query35	840	872	816	816
query36	994	1029	920	920
query37	142	121	94	94
query38	3653	3599	3554	3554
query39	1482	1423	1430	1423
query40	223	129	119	119
query41	65	62	67	62
query42	125	112	177	112
query43	492	492	471	471
query44	1311	845	813	813
query45	184	178	169	169
query46	844	996	625	625
query47	1804	1818	1757	1757
query48	414	445	319	319
query49	771	513	417	417
query50	639	690	406	406
query51	3879	3969	3932	3932
query52	114	106	97	97
query53	245	265	200	200
query54	596	588	518	518
query55	92	85	79	79
query56	347	298	311	298
query57	1189	1207	1126	1126
query58	285	274	271	271
query59	2632	2706	2548	2548
query60	349	336	320	320
query61	153	148	150	148
query62	797	722	697	697
query63	232	206	199	199
query64	4400	1158	839	839
query65	4055	3971	3979	3971
query66	1093	426	320	320
query67	15326	15188	14984	14984
query68	7967	934	586	586
query69	478	340	293	293
query70	1323	1263	1295	1263
query71	530	331	322	322
query72	5843	5075	4872	4872
query73	641	588	372	372
query74	8791	9094	8996	8996
query75	3967	3374	2854	2854
query76	3673	1154	728	728
query77	812	381	409	381
query78	9682	9862	8880	8880
query79	2016	839	606	606
query80	622	573	509	509
query81	489	255	228	228
query82	479	159	127	127
query83	275	264	263	263
query84	247	108	100	100
query85	922	464	417	417
query86	340	316	289	289
query87	3728	3747	3630	3630
query88	3733	2244	2232	2232
query89	388	331	297	297
query90	2027	220	274	220
query91	162	169	135	135
query92	83	69	63	63
query93	1758	989	638	638
query94	701	450	335	335
query95	406	329	311	311
query96	481	572	277	277
query97	2968	2991	2847	2847
query98	240	215	210	210
query99	1389	1401	1359	1359
Total cold run time: 278735 ms
Total hot run time: 190296 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.05
query2	0.09	0.06	0.05
query3	0.25	0.09	0.08
query4	1.60	0.12	0.12
query5	0.28	0.27	0.26
query6	1.18	0.65	0.65
query7	0.03	0.03	0.03
query8	0.05	0.05	0.05
query9	0.63	0.52	0.52
query10	0.59	0.58	0.59
query11	0.17	0.15	0.11
query12	0.16	0.11	0.12
query13	0.64	0.61	0.62
query14	1.03	1.03	1.04
query15	0.88	0.85	0.86
query16	0.39	0.39	0.41
query17	1.05	1.02	1.06
query18	0.22	0.20	0.20
query19	1.92	1.82	1.82
query20	0.02	0.02	0.01
query21	15.47	0.91	0.58
query22	0.76	1.37	0.90
query23	14.70	1.39	0.68
query24	7.48	0.91	0.43
query25	0.50	0.35	0.06
query26	0.59	0.15	0.13
query27	0.07	0.05	0.06
query28	9.05	1.35	0.91
query29	12.60	3.95	3.26
query30	0.29	0.13	0.11
query31	2.83	0.60	0.39
query32	3.23	0.55	0.48
query33	3.06	3.06	3.10
query34	16.18	5.49	4.82
query35	4.93	4.91	4.89
query36	0.68	0.52	0.50
query37	0.10	0.07	0.07
query38	0.06	0.05	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.15
query41	0.08	0.04	0.03
query42	0.04	0.02	0.02
query43	0.05	0.03	0.03
Total cold run time: 104.2 s
Total hot run time: 30.16 s

@mrhhsg
Copy link
Member Author

mrhhsg commented Oct 16, 2025

run buildall

@doris-robot
Copy link

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

query1	0.06	0.04	0.04
query2	0.09	0.05	0.05
query3	0.26	0.09	0.09
query4	1.61	0.12	0.12
query5	0.28	0.27	0.25
query6	1.20	0.67	0.65
query7	0.04	0.03	0.03
query8	0.05	0.04	0.04
query9	0.64	0.53	0.51
query10	0.59	0.58	0.61
query11	0.17	0.11	0.11
query12	0.15	0.12	0.12
query13	0.63	0.61	0.62
query14	1.02	1.04	1.02
query15	0.86	0.87	0.86
query16	0.41	0.41	0.41
query17	1.05	1.07	1.02
query18	0.21	0.20	0.20
query19	1.96	1.83	1.85
query20	0.02	0.02	0.01
query21	15.43	0.95	0.57
query22	0.77	1.09	0.67
query23	14.99	1.38	0.64
query24	6.73	1.56	0.40
query25	0.38	0.21	0.13
query26	0.63	0.15	0.12
query27	0.07	0.06	0.05
query28	9.45	1.40	0.93
query29	12.60	3.94	3.28
query30	0.28	0.15	0.12
query31	2.83	0.61	0.40
query32	3.23	0.56	0.51
query33	3.18	3.15	3.16
query34	16.14	5.44	4.84
query35	5.01	4.89	4.88
query36	0.69	0.53	0.52
query37	0.11	0.08	0.07
query38	0.06	0.05	0.05
query39	0.04	0.03	0.03
query40	0.18	0.15	0.15
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.03	0.04
Total cold run time: 104.28 s
Total hot run time: 30.15 s

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 76.19% (32/42) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.54% (17818/33910)
Line Coverage 37.75% (161927/428959)
Region Coverage 32.22% (123568/383481)
Branch Coverage 33.61% (54226/161328)

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 40.91% (9/22) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (42/42) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.25% (23689/33249)
Line Coverage 57.71% (247420/428717)
Region Coverage 52.85% (205276/388445)
Branch Coverage 54.61% (88587/162223)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (42/42) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.23% (23682/33249)
Line Coverage 57.67% (247241/428717)
Region Coverage 52.79% (205055/388445)
Branch Coverage 54.58% (88537/162223)

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (22/22) 🎉
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 Oct 17, 2025
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit 50123ad into apache:master Oct 17, 2025
26 of 28 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 17, 2025
… in the EXPLODE function (#57050)

### What problem does this PR solve?

Since the EXPLODE function supports multiple arguments, its return value
is defined as a STRUCT type. Even when it has only a single argument, it
still returns a STRUCT.
Consider the following example:

```sql
SELECT * 
FROM (SELECT 1) t1 
LATERAL VIEW explode(array(struct('a', 1), struct('b', 2))) t2 AS c1, c2;
```

```text
+------+------------------------+
| 1    | c1                     |
+------+------------------------+
|    1 | {"col1":"a", "col2":1} |
|    1 | {"col1":"b", "col2":2} |
+------+------------------------+
```

In this SQL statement, the return value of the EXPLODE function is a
nested STRUCT (that is, the child column inside the struct is struct
too).
As a result, the final output extracts the child column from the outer
struct, but those child columns themselves are not correctly assigned to
c1 and c2.

With this PR, the result will be like this:
```text
+------+------+------+
| 1    | c1   | c2   |
+------+------+------+
|    1 | a    |    1 |
|    1 | b    |    2 |
+------+------+------+
```

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] 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 Oct 17, 2025
…ype argument in the EXPLODE function #57050 (#57093)

Cherry-picked from #57050

Co-authored-by: Jerry Hu <hushenggang@selectdb.com>
@dataroaring dataroaring added usercase Important user case type label dev/3.1.x labels Nov 6, 2025
mrhhsg added a commit to mrhhsg/doris that referenced this pull request Nov 8, 2025
…ype argument in the EXPLODE function (apache#57050)

Cherry-picked from apache#57050

Co-authored-by: Jerry Hu <hushenggang@selectdb.com>
morrySnow pushed a commit that referenced this pull request Nov 10, 2025
…ype argument in the EXPLODE function #57050 (#57827)

Cherry-picked from #57050

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mrhhsg mrhhsg deleted the opt_explode branch November 11, 2025 01:45
w41ter pushed a commit to w41ter/incubator-doris that referenced this pull request Dec 26, 2025
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.3-merged dev/4.0.1-merged reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants