Skip to content

[refine](column) backport strong typed column helpers to 4.1#64960

Merged
yiguolei merged 4 commits into
apache:branch-4.1from
Mryange:branch-4.1-pick-column-strong-types-20260629
Jun 30, 2026
Merged

[refine](column) backport strong typed column helpers to 4.1#64960
yiguolei merged 4 commits into
apache:branch-4.1from
Mryange:branch-4.1-pick-column-strong-types-20260629

Conversation

@Mryange

@Mryange Mryange commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Related PR: #63491, #63678, #63946, #58092

Problem Summary:

Backport the column strong-typing refinements for branch-4.1: use strong typed nullable null maps, array offsets, and map offsets, and apply the column check helper for type casts. Branch-4.1 was missing the COW/Column cast helper introduced by #58092, so this also ports the minimal helper API needed by the picked changes and adjusts an old array distance code path to use the already strong typed offsets pointer.

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

Mryange added 4 commits June 29, 2026 17:57
…ullable (apache#63491)

The null_map column in `ColumnNullable` was stored as a generic
`IColumn::WrappedPtr`, requiring `assert_cast<ColumnUInt8>` at every
call site that accessed it. This had two problems:
1. **Redundant runtime casts**: Every access to `get_null_map_column()`
or `get_null_map_column_ptr()` performed an `assert_cast`, adding
unnecessary overhead on hot paths (filter evaluation, null propagation,
etc.).
2. **Type safety**: The generic `WrappedPtr` type provided no
compile-time guarantee that the null map is always a `ColumnUInt8`,
making it possible to accidentally store a wrong column type.

Root cause: The `_null_map` member was typed as a generic
`IColumn::WrappedPtr` instead of the concrete `ColumnUInt8::WrappedPtr`.

Fix: Change `_null_map` to `ColumnUInt8::WrappedPtr` so the type is
fixed at the member level. The constructor now validates and converts to
`ColumnUInt8::MutablePtr` on entry via a helper
`assert_mutable_null_map()`. All call sites that previously did
`assert_cast<ColumnUInt8>` now get the correct type directly.

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 d0536c0)
Array and map offset subcolumns were still stored and exposed through
generic IColumn pointers, so callers had to repeatedly downcast them
back to their concrete offset column types. Root cause: the ownership,
COW mutation, deserialization, and segment reader write-back paths still
treated these offsets as generic subcolumns, which left the
strong-typing change incomplete and kept redundant same-type assert_cast
usage in affected callers and tests. This change promotes ColumnArray
offsets and ColumnMap offsets_column to typed wrapped pointers, updates
the typed accessors and generic write-back paths to preserve the
concrete offset column type, and removes the now-redundant casts in
array functions, lambda functions, and unit tests. It also cleans up one
redundant nullable null-map cast uncovered during the BE UT compile.

None

(cherry picked from commit 2ad56a8)
Problem Summary: Replace direct typeid_cast usage for Doris column type
checks with the column-specific check_and_get_column helper. This keeps
column downcast checks consistent across core column code, expression
evaluation, storage segment code, and related table reader tests without
changing behavior.

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 0f73bd6)
@Mryange Mryange requested a review from yiguolei as a code owner June 29, 2026 12:08
@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 Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 66.46% (216/325) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.56% (20815/38154)
Line Coverage 38.08% (198596/521500)
Region Coverage 34.56% (155937/451154)
Branch Coverage 35.52% (67973/191384)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 85.67% (275/321) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.76% (27492/37272)
Line Coverage 57.40% (297866/518962)
Region Coverage 55.06% (250097/454224)
Branch Coverage 56.44% (108178/191669)

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 30, 2026
@yiguolei yiguolei merged commit e9c8dd4 into apache:branch-4.1 Jun 30, 2026
29 of 32 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

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.

3 participants