Skip to content

[opt](be) Backport nullable and projection optimizations to branch-4.1 - #66586

Open
Mryange wants to merge 3 commits into
apache:branch-4.1from
Mryange:branch-4.1-pick-66031-66085
Open

[opt](be) Backport nullable and projection optimizations to branch-4.1#66586
Mryange wants to merge 3 commits into
apache:branch-4.1from
Mryange:branch-4.1-pick-66031-66085

Conversation

@Mryange

@Mryange Mryange commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Related PR: #66031, #66085

Mryange added 2 commits August 7, 2026 17:04
apache#66031)

The default nullable function path independently inspected the same null
maps when checking for all-NULL arguments, unnesting nullable inputs,
and wrapping function results. This caused redundant full null-map scans
and made type-level nullable checks difficult to distinguish from
runtime NULL-value checks.

This change introduces `NullableColumnInfo` to collect the nested
column, typed null-map column, constness, and non-NULL count once per
input column. The information is reused across nullable unnesting, CAST
handling, and result wrapping. It also renames the type-level helper to
`has_nullable_argument_type` and preserves the existing copy-on-write
behavior by copying nested data only when NULL payloads must be replaced
with defaults.

(cherry picked from commit a4423dc)
…66085)

Projection results were converted to mutable columns before being
published. Shared results such as SlotRef columns therefore triggered
COW clones and full-column copies.

This change keeps scoped output-block reuse while moving exclusive
results directly and publishing shared immutable columns after restore.
It also makes `ColumnConst` and `ColumnVariant` ownership checks include
their nested columns, and uses actual peak memory tracking instead of
charging shared input buffers as projection allocations.

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

(cherry picked from commit c611239)
@Mryange
Mryange requested a review from yiguolei as a code owner August 7, 2026 12:33
@hello-stephen

Copy link
Copy Markdown
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?

@Mryange

Mryange commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@Mryange

Mryange commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

1 similar comment
@yiguolei

yiguolei commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants