Skip to content

[fix](topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) - #67928

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
liutang123:fix-topn-lazy-non-lsc-table-4.1
Sep 15, 2026
Merged

yiguolei merged 1 commit into
apache:branch-4.1from
liutang123:fix-topn-lazy-non-lsc-table-4.1

Conversation

@liutang123

Copy link
Copy Markdown
Contributor

bp #65415

…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 |
@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?

@liutang123

Copy link
Copy Markdown
Contributor Author

run buildall

@liutang123 liutang123 changed the title [branch-4.1](topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) [branch-4.1] (topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) Sep 14, 2026
@liutang123 liutang123 changed the title [branch-4.1] (topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) [fix] (topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) Sep 14, 2026
@liutang123 liutang123 changed the title [fix] (topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) [fix](topn lazy materialization) Disable topn lazy materialization on non-light-schema-change tables (#65415) Sep 14, 2026
@liutang123

Copy link
Copy Markdown
Contributor Author

run check_coverage_fe

@liutang123

Copy link
Copy Markdown
Contributor Author

run p0

@liutang123

Copy link
Copy Markdown
Contributor Author

run check_coverage_fe

@yiguolei

Copy link
Copy Markdown
Contributor

skip buildall

@yiguolei
yiguolei merged commit a514f2b into apache:branch-4.1 Sep 15, 2026
60 of 67 checks passed
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