[fix](topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) - #67928
Merged
yiguolei merged 1 commit intoSep 15, 2026
Conversation
…on non-light-schema-change tables (apache#65415) A top-N query that emits a non-order-by column fails on a **non-light-schema-change** OLAP table (a table created/upgraded with `light_schema_change = false`, where every column's `uniqueId` is `-1`): ```sql select id, name from tbl order by createdate desc limit 10; ``` ``` ERROR 1105 (HY000): errCode = 2, detailMessage = [INTERNAL_ERROR]field name is invalid. field=__DORIS_GLOBAL_ROWID_COL__tbl, field_name_to_index=[...], col_unique_id=2147483647 ``` Fix: disable topn lazy materialization for non-light-schema-change OLAP tables in MaterializeProbeVisitor and fall back to normal topn (the working two-phase read path). A new helper supportOlapTopnLazyMaterialize() consolidates the existing AGG_KEYS exclusion with the new light_schema_change requirement, applied at visitPhysicalOlapScan, visitPhysicalCatalogRelation and visitPhysicalFilter. Add regression test topn_lazy_light_schema_change verifying: - light_schema_change=false: no lazy materialization in the plan, correct results. - light_schema_change=true: lazy materialization still applies, correct results. ## Behavior after the fix | Table | Plan | Result | |-------|------|--------| | `light_schema_change = false` | plain `PhysicalOlapScan` (no lazy) → safe two-phase read | correct values | | `light_schema_change = true` | `PhysicalLazyMaterialize` / `PhysicalLazyMaterializeOlapScan` (unchanged) | correct values |
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
Author
|
run check_coverage_fe |
Contributor
Author
|
run p0 |
Contributor
Author
|
run check_coverage_fe |
Contributor
|
skip buildall |
yiguolei
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bp #65415