Skip to content

[branch-4.1][fix](be) Preserve nested paths for lazy rowid fetch#65260

Open
mrhhsg wants to merge 2 commits into
apache:branch-4.1from
mrhhsg:backport-64242-branch-4.1
Open

[branch-4.1][fix](be) Preserve nested paths for lazy rowid fetch#65260
mrhhsg wants to merge 2 commits into
apache:branch-4.1from
mrhhsg:backport-64242-branch-4.1

Conversation

@mrhhsg

@mrhhsg mrhhsg commented Jul 6, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: None

Related PR: #64242

Problem Summary:

Backport #64242 to branch-4.1. Preserve nested access paths for TopN lazy materialization rowid fetch, avoid row-store fetch when lazy slots carry nested access paths, and keep struct iterators readable when child fields are pruned.

Backport note: branch-4.1 still uses the single-row seek_and_read_by_rowid(...) API in one rowid-fetch path, so the cherry-pick conflict was resolved by setting slot access paths before the existing per-row fetch loop.

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:
      • Previous test can cover this change. The original PR [fix](be) Preserve nested paths for lazy rowid fetch #64242 added FE UT and regression coverage; this is a branch-4.1 backport with conflict resolution for the rowid fetch API difference.
      • This is a refactor/code format and no logic has been changed.
      • 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

@mrhhsg mrhhsg requested a review from yiguolei as a code owner July 6, 2026 09:28
@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?

[fix](be) Preserve nested paths for lazy rowid fetch

Issue Number: None

Problem Summary: TopN lazy materialization can fetch nested-pruned
columns by row id after nested-column pruning. The probe must keep the
relation output slot metadata; otherwise the slot remapped to the TopN
output ExprId can lose nested access paths. Then FE may consider a
nested-pruned lazy slot safe for row-store fetch, while BE row-store
fetch maps values only by column unique id and cannot apply sub-column
or nested access paths. This patch preserves relation slot access paths
through lazy materialization, passes slot access paths to the normal
storage rowid fetch path, rejects row-store fetch only for lazy slots
that actually carry sub-column paths or nested access paths, and keeps
struct iterators readable when child fields are pruned.

None

- Test:
- Build:
~/.codex/skills/doris-local-regression/scripts/doris-local-regression.sh
--network 10.26.20.3/24 build
    - Build: ./build.sh --fe
- Unit Test: ./run-fe-ut.sh --run
org.apache.doris.nereids.glue.translator.PhysicalPlanTranslatorTest,org.apache.doris.nereids.processor.post.materialize.MaterializeProbeVisitorTest
- Regression test:
~/.codex/skills/doris-local-regression/scripts/doris-local-regression.sh
--network 10.26.20.3/24 run -d nereids_rules_p0/column_pruning -s
topn_lazy_nested_column_pruning
- Format: build-support/clang-format.sh be/src/exec/rowid_fetcher.cpp
    - Check: git diff --check
- Behavior changed: No
- Does this need documentation: No

---------

Co-authored-by: lihangyu <lihangyu@selectdb.com>
(cherry picked from commit 6a7fc86)
@mrhhsg mrhhsg force-pushed the backport-64242-branch-4.1 branch from 1bbed3d to be09eb6 Compare July 6, 2026 09:33
@mrhhsg

mrhhsg commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

/review

@mrhhsg

mrhhsg commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

run buildall

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found three blocking issues in this backport.

Critical checkpoints:

  • Existing inline review threads: none were present, so no accepted comment duplicates an existing thread.
  • Required AGENTS.md files: the provided required list was empty.
  • Repo-local code-review skill: not found in this checkout after hidden-path and content searches, so I followed the review prompt and shared-ledger workflow directly.
  • Validation: git diff --check 27eda17673797a507474b04263d26681b4cd1f0a be09eb6f6d9220a1dc68b9e670c2a108722dd8d7 passed. thirdparty/installed and thirdparty/installed/bin/protoc are absent in this runner, so I did not run full FE/BE tests; two comments are direct source-proven Java compile blockers.

User focus: no additional user-provided focus points were supplied.

Subagent conclusions: OPT-1 became inline comment MAIN-1. TSC-1 and TSC-2 became inline comments MAIN-2 and MAIN-3. No candidates were dismissed or merged as duplicates. Convergence round 1 ended with both optimizer-rewrite and tests-session-config replying NO_NEW_VALUABLE_FINDINGS for the same MAIN-1/MAIN-2/MAIN-3 comment set.


Set<Slot> requiredMaterializedSlots = new HashSet<>();
requiredMaterializedSlots.add(baseSlot);
MaterializeProbeVisitor.ProbeContext context = new MaterializeProbeVisitor.ProbeContext(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test class will not compile: ProbeContext only has the single-argument constructor ProbeContext(SlotReference slot), but this and two later tests call new ProbeContext(slot, requiredMaterializedSlots). Please either add the intended constructor/state to MaterializeProbeVisitor.ProbeContext or rewrite these tests to use the current API before landing the UT.


package org.apache.doris.nereids.processor.post.materialize;

import org.apache.doris.analysis.ColumnAccessPath;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is unresolved in this branch. There is no org.apache.doris.analysis.ColumnAccessPath class or ColumnAccessPath.data(...) helper in the repo; the existing access-path representation is the thrift TColumnAccessPath/TDataAccessPath/TAccessPathType types. As written, the new UT fails at compilation before it can exercise the PR.

return Optional.empty();
}
return Optional.of(new MaterializeSource(scan, context.slot));
return Optional.of(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still does not get the nested access paths to BE. The visitor now returns the relation output slot, but the slot that becomes the materialization tuple descriptor is rebuilt later from the original lazy slot: PhysicalLazyMaterialize does ((SlotReference) lazySlot).withColumn(originalColumn), and withColumn() does not copy allAccessPaths/predicateAccessPaths. generateTupleDesc(materialize.getOutput(), ...) therefore creates a SlotDescriptor with empty access paths, so the new set_slot_access_paths() calls in BE are a no-op for the targeted rowid fetch. Please carry MaterializeSource.baseSlot's access paths onto the lazy output slot that is serialized for the fetch request, and add a test that checks the materialization tuple descriptor contains those paths.

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/20) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.78% (20953/38251)
Line Coverage 38.21% (199955/523339)
Region Coverage 34.69% (157026/452668)
Branch Coverage 35.63% (68523/192345)

@mrhhsg

mrhhsg commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

run compile

@mrhhsg

mrhhsg commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 25.81% (8/31) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/20) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.81% (20967/38253)
Line Coverage 38.23% (200076/523367)
Region Coverage 34.71% (157138/452709)
Branch Coverage 35.65% (68570/192369)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.00% (16/20) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.84% (27600/37376)
Line Coverage 57.50% (299472/520866)
Region Coverage 55.16% (251415/455797)
Branch Coverage 56.48% (108819/192661)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 64.52% (20/31) 🎉
Increment coverage report
Complete coverage report

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.

2 participants