Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #57050

… 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 -->
@github-actions github-actions bot requested a review from yiguolei as a code owner October 17, 2025 04:08
@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?

@dataroaring dataroaring reopened this Oct 17, 2025
@hello-stephen
Copy link
Contributor

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.11	0.03	0.03
query3	0.26	0.07	0.07
query4	1.62	0.12	0.11
query5	0.26	0.26	0.25
query6	1.20	0.64	0.64
query7	0.03	0.02	0.02
query8	0.06	0.04	0.04
query9	0.62	0.52	0.52
query10	0.56	0.56	0.58
query11	0.17	0.12	0.11
query12	0.16	0.12	0.12
query13	0.64	0.61	0.60
query14	0.80	0.84	0.82
query15	0.91	0.86	0.83
query16	0.39	0.41	0.41
query17	1.05	1.07	1.04
query18	0.19	0.19	0.19
query19	1.93	1.82	1.90
query20	0.02	0.01	0.01
query21	15.41	0.93	0.58
query22	0.78	1.18	0.73
query23	15.11	1.42	0.64
query24	16.29	1.51	0.61
query25	2.19	0.39	0.21
query26	0.19	0.19	0.19
query27	0.21	0.20	0.21
query28	1.72	1.07	0.98
query29	12.69	3.99	3.30
query30	0.31	0.14	0.13
query31	2.88	0.59	0.38
query32	3.24	0.56	0.46
query33	2.98	3.15	3.20
query34	16.50	5.40	5.14
query35	5.16	5.16	5.32
query36	0.74	0.56	0.58
query37	0.12	0.07	0.07
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.14
query41	0.09	0.04	0.03
query42	0.04	0.02	0.02
query43	0.06	0.03	0.02
Total cold run time: 108.02 s
Total hot run time: 30.99 s

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

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

@github-actions
Copy link
Contributor Author

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit a13b90a into branch-4.0 Oct 17, 2025
23 of 27 checks passed
@github-actions github-actions bot deleted the auto-pick-57050-branch-4.0 branch October 17, 2025 09:29
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