Skip to content

[opt](explode) Optimize explode_outer and posexplode (#62069)#62145

Merged
yiguolei merged 1 commit intoapache:branch-4.1from
jacktengg:branch-4.1
Apr 7, 2026
Merged

[opt](explode) Optimize explode_outer and posexplode (#62069)#62145
yiguolei merged 1 commit intoapache:branch-4.1from
jacktengg:branch-4.1

Conversation

@jacktengg
Copy link
Copy Markdown
Contributor

Issue Number: Pick #62069

Related PR: #xxx

Problem Summary:

Improvement of #60352, optimize explode_outer, posexplode and posexplode_outer.

The approach is a single-pass algorithm: walk through child rows, accumulating contiguous segments into the output, then when hitting a null/empty row or reaching the end, flush the segment using bulk operations. For outer-null rows, insert a NULL and copy the non-table-function columns directly. This naturally handles both outer and
non-outer modes since non-outer mode just won't produce any null outputs. For posexplode, generate position indices alongside this.

Performance test result.
Create and populate a large test table. Use 100,000,000 base rows, each with an array of 10 INT elements, producing 1,000,000,000 total exploded output rows.

Function slow path optimized SpeedUp
explode 9734 ms 5105 ms 90%
explode_outer 9685 ms 5064 ms 91%
posexplode 11021 ms 5963 ms 84%
posexplode_outer 14088 ms 5903 ms 138%

None

  • 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.

  • Confirm the release note

  • Confirm test cases

  • Confirm document

  • Add branch pick label

What problem does this PR solve?

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

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Improvement of apache#60352, optimize explode_outer, posexplode and
posexplode_outer.

The approach is a single-pass algorithm: walk through child rows,
accumulating contiguous segments into the output, then when hitting a
null/empty row or reaching the end, flush the segment using bulk
operations. For outer-null rows, insert a NULL and copy the
non-table-function columns directly. This naturally handles both outer
and
non-outer modes since non-outer mode just won't produce any null
outputs. For posexplode, generate position indices alongside this.

Performance test result.
Create and populate a large test table. Use 100,000,000 base rows, each
with an array of 10 INT elements, producing 1,000,000,000 total exploded
output rows.

| Function | slow path | optimized | SpeedUp|
| --------- |---------- |-----------|----------|
| explode | 9734 ms | 5105 ms |90%|
| explode_outer | 9685 ms | 5064 ms |91%|
| posexplode | 11021 ms | 5963 ms |84%|
| posexplode_outer | 14088 ms | 5903 ms |138%|

None

- 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 -->

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
@jacktengg jacktengg requested a review from yiguolei as a code owner April 7, 2026 02:54
@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 7, 2026

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?

@jacktengg
Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

PR approved by anyone and no changes requested.

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 88.72% (118/133) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.96% (19828/37438)
Line Coverage 36.46% (186446/511326)
Region Coverage 32.72% (144409/441323)
Branch Coverage 33.90% (63394/186990)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 87.10% (189/217) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.18% (26799/36620)
Line Coverage 56.62% (288393/509304)
Region Coverage 54.19% (241148/445019)
Branch Coverage 55.81% (104606/187426)

@yiguolei yiguolei merged commit 96b9388 into apache:branch-4.1 Apr 7, 2026
27 of 29 checks passed
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.

4 participants