Skip to content

[refactor](be) Unify storage reader column ordinals - #66472

Open
csun5285 wants to merge 5 commits into
apache:masterfrom
csun5285:refactor/reader-return-columns
Open

[refactor](be) Unify storage reader column ordinals#66472
csun5285 wants to merge 5 commits into
apache:masterfrom
csun5285:refactor/reader-return-columns

Conversation

@csun5285

@csun5285 csun5285 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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

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

@csun5285
csun5285 force-pushed the refactor/reader-return-columns branch 2 times, most recently from 6a3b439 to 768a009 Compare August 7, 2026 12:27
@csun5285

csun5285 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29131 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 768a0090d6d77fef5a40d4a42f3daad744c933f7, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17707	4084	3969	3969
q2	2013	334	195	195
q3	10307	1380	799	799
q4	4683	464	339	339
q5	7510	852	553	553
q6	186	163	141	141
q7	742	808	611	611
q8	9335	1411	1477	1411
q9	5307	4089	4061	4061
q10	6798	1623	1360	1360
q11	504	366	324	324
q12	735	565	439	439
q13	18078	3670	2730	2730
q14	264	266	253	253
q15	q16	730	726	658	658
q17	1001	1077	1009	1009
q18	6508	5615	5534	5534
q19	1178	1250	1153	1153
q20	789	676	558	558
q21	6133	2876	2725	2725
q22	457	381	309	309
Total cold run time: 100965 ms
Total hot run time: 29131 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4927	4543	4590	4543
q2	295	320	207	207
q3	4880	5209	4737	4737
q4	2176	2256	1400	1400
q5	4496	4541	4391	4391
q6	229	186	146	146
q7	1888	1726	1497	1497
q8	2333	2014	1989	1989
q9	7135	6825	6660	6660
q10	4261	4223	3809	3809
q11	512	367	335	335
q12	688	694	492	492
q13	2953	3320	2737	2737
q14	265	278	249	249
q15	q16	672	679	618	618
q17	1221	1208	1199	1199
q18	12174	10958	11683	10958
q19	1105	1065	1084	1065
q20	2186	2190	1900	1900
q21	5170	4605	4522	4522
q22	512	446	414	414
Total cold run time: 60078 ms
Total hot run time: 53868 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 79.00% (79/100) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 158453 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 768a0090d6d77fef5a40d4a42f3daad744c933f7, data reload: false

query5	4319	579	452	452
query6	462	220	227	220
query7	4856	613	345	345
query8	321	169	160	160
query9	8773	3988	3960	3960
query10	452	366	299	299
query11	5847	2202	2033	2033
query12	149	96	94	94
query13	1254	588	423	423
query14	6072	4241	3979	3979
query14_1	3775	3747	3772	3747
query15	206	197	176	176
query16	1004	469	447	447
query17	960	682	529	529
query18	2428	454	321	321
query19	201	180	139	139
query20	105	100	102	100
query21	234	155	135	135
query22	13043	12972	12782	12782
query23	15908	15121	14563	14563
query23_1	14728	14730	14685	14685
query24	7467	1700	1226	1226
query24_1	1253	1219	1199	1199
query25	524	466	356	356
query26	1303	353	216	216
query27	2587	628	375	375
query28	4554	1986	2005	1986
query29	1053	586	467	467
query30	338	260	222	222
query31	1179	1117	1052	1052
query32	109	61	61	61
query33	527	298	234	234
query34	1214	1159	649	649
query35	721	748	624	624
query36	769	772	675	675
query37	159	103	88	88
query38	1831	1746	1663	1663
query39	827	827	803	803
query39_1	794	781	784	781
query40	246	166	145	145
query41	66	71	64	64
query42	98	95	90	90
query43	320	321	277	277
query44	1412	759	760	759
query45	186	179	180	179
query46	1070	1161	743	743
query47	1572	1557	1446	1446
query48	404	396	298	298
query49	573	412	295	295
query50	1041	436	336	336
query51	10747	10767	10807	10767
query52	88	88	82	82
query53	274	280	201	201
query54	303	259	233	233
query55	78	80	69	69
query56	331	324	301	301
query57	1041	975	930	930
query58	316	282	261	261
query59	1539	1601	1372	1372
query60	322	291	275	275
query61	179	183	177	177
query62	395	327	273	273
query63	241	194	200	194
query64	3012	1179	978	978
query65	3900	3817	3793	3793
query66	1842	498	380	380
query67	20056	20028	19936	19936
query68	3392	1642	1051	1051
query69	431	303	274	274
query70	910	799	772	772
query71	370	354	332	332
query72	3232	2827	2320	2320
query73	824	750	459	459
query74	4632	4481	4281	4281
query75	2366	2344	1983	1983
query76	2423	1155	747	747
query77	339	356	277	277
query78	11182	11120	10552	10552
query79	1438	1195	772	772
query80	663	532	469	469
query81	488	338	293	293
query82	629	166	130	130
query83	409	326	306	306
query84	325	163	129	129
query85	938	612	524	524
query86	315	229	216	216
query87	1961	1950	1828	1828
query88	3688	2793	2764	2764
query89	387	316	279	279
query90	1939	190	189	189
query91	202	185	168	168
query92	64	65	56	56
query93	1568	1575	947	947
query94	535	338	311	311
query95	774	488	481	481
query96	1058	834	353	353
query97	2447	2452	2332	2332
query98	196	183	180	180
query99	753	718	605	605
Total cold run time: 244954 ms
Total hot run time: 158453 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.85 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 768a0090d6d77fef5a40d4a42f3daad744c933f7, data reload: false

query1	0.00	0.00	0.00
query2	0.09	0.04	0.04
query3	0.25	0.13	0.13
query4	1.62	0.14	0.13
query5	0.23	0.21	0.22
query6	1.17	0.81	0.79
query7	0.04	0.01	0.01
query8	0.06	0.03	0.04
query9	0.37	0.30	0.33
query10	0.57	0.58	0.60
query11	0.18	0.14	0.13
query12	0.18	0.14	0.14
query13	0.46	0.46	0.48
query14	1.00	1.00	0.98
query15	0.60	0.60	0.58
query16	0.33	0.32	0.31
query17	1.14	1.10	1.08
query18	0.22	0.19	0.20
query19	1.98	1.98	1.97
query20	0.02	0.01	0.01
query21	15.44	0.20	0.13
query22	4.96	0.05	0.05
query23	16.36	0.30	0.12
query24	2.95	0.42	0.31
query25	0.12	0.04	0.04
query26	0.72	0.21	0.14
query27	0.04	0.03	0.03
query28	3.57	0.76	0.37
query29	12.52	4.08	3.22
query30	0.27	0.16	0.16
query31	2.76	0.56	0.31
query32	3.22	0.59	0.48
query33	3.18	3.21	3.19
query34	15.58	3.94	3.24
query35	3.27	3.21	3.23
query36	0.54	0.43	0.43
query37	0.09	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.14
query41	0.09	0.03	0.03
query42	0.03	0.02	0.02
query43	0.05	0.04	0.03
Total cold run time: 96.53 s
Total hot run time: 23.85 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 84.00% (84/100) 🎉
Increment coverage report
Complete coverage report

csun5285 added a commit to csun5285/doris that referenced this pull request Aug 9, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66472

Problem Summary: The reader-schema refactor renamed storage block and schema APIs, but several BE tests still used the old interfaces. The FE translator test also left row-binlog index replicas behind the partition version, and one DATETIMEV2 fixture omitted its scale. Update these test fixtures so the refactored reader code is compiled and exercised correctly.

### Release note

None

### Check List (For Author)

- Test: Unit Test and build
    - ASAN BE and FE build
    - PhysicalPlanTranslatorTest: 13 tests passed
    - Reader-related BE UT: 71 tests passed
    - clang-format and clang-tidy passed
- Behavior changed: No
- Does this need documentation: No
@csun5285
csun5285 force-pushed the refactor/reader-return-columns branch from 768a009 to aff0dbe Compare August 9, 2026 14:20
@csun5285

csun5285 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@csun5285

csun5285 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review step was failure (possibly timeout or cancelled)
Workflow run: https://github.com/apache/doris/actions/runs/31318703378

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@csun5285

Copy link
Copy Markdown
Contributor Author

run buildall

@csun5285

Copy link
Copy Markdown
Contributor Author

/review

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

Requesting changes for two P1 correctness/compatibility blockers in the new FE-authored ReadSchema contract.

Critical checkpoints:

  • Goal and tests: The ordinal unification is coherent on most current-FE paths, but the added tests primarily assert descriptor shape; they do not prove lazy scan outcomes or mixed-version execution.
  • Scope: Reviewed the complete 124-file authoritative diff and the upstream/downstream FE scan, BE reader, merge, index, schema-change, compaction, cloud, binlog, snapshot, rowid, and test paths.
  • Concurrency: No new race was substantiated; shared read-schema mutation is copy-before-publish and occurs before rowset-reader context capture.
  • Lifecycle: Delete-predicate suffix construction, reader initialization, segment state sizing, and visible-prefix output boundaries are coherent.
  • Configuration: The lazy bug is reachable under the existing TopN lazy-materialization threshold; no separate configuration/default regression was found.
  • Compatibility: Blocking issue inline: an older FE can send the same accepted execution version while omitting dependencies that this BE now assumes are present.
  • Parallel paths: Query/direct readers, vertical readers, schema change, compaction, cloud, inverted/ANN, and rowid paths were traced; the distinct missed parallel path is lazy scan translation.
  • Conditions: Key/value predicate ordinal binding, TSO predicate creation, condition-cache fencing, and historical delete conditions were checked; no additional issue survived.
  • Test coverage/results: No local build or tests were run, as required by the review environment. Visible CI has successful BE UT (macOS), CheckStyle, Clang Formatter, license, secrets, and dependency checks; other displayed jobs are skipped, and this automated review status is pending until submission.
  • Observability: The ReadSchema profile output is useful and no logging/profile correctness issue was found.
  • Persistence/transactions: The runtime-only schema object does not alter persisted metadata; rowset versions, delete history, snapshot fences, and transaction-facing row images were reviewed.
  • Data writes: Writer, memtable, compaction, and rowid-conversion edits are mechanical ordinal/schema migrations with no substantiated write-path defect.
  • FE/BE variables: be_exec_version=11 does not encode the new tuple-completeness capability, which is the compatibility blocker noted inline.
  • Performance: No clear performance regression was found in the ordinal maps, column state, or reader construction changes.
  • Other issues: Blocking issue inline: lazy translation can remove keys and snapshot/binlog helper slots before BE constructs ReadSchema.

User focus: review_focus.txt contained no additional focus beyond the full PR review.

Review completion: The full-scope and risk-focused passes converged in Round 2 with no unresolved candidates.

.collect(Collectors.toSet());

olapScanNode.updateRequiredSlots(context, scanIds);
preserveMergeSequenceSlots(olapScanNode, scanIds);

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.

[P1] Preserve the full storage dependency set for lazy scans

This second pruning pass bypasses the normal calls to preserveStorageSemanticSlots() and preserveExtraStorageKeySlots(). For the new test query, k1/k2 are lazy, so the scan descriptor keeps v1/sequence/rowid but drops the key prefix; BE then builds a ReadSchema with zero key columns and can merge distinct MOR keys as equal. Lazy snapshot/binlog scans similarly lose commit-TSO or TSO/op/before slots and fail initialization. Apply the same two preservation steps used by updateScanSlotsMaterialization before removing tuple slots.

return Status::InternalError("failed to build storage scanner, no materialized slot!");
}

// The FE physical scan tuple is the read-path schema. It already includes

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.

[P1] Keep a fallback for plans from older FEs

This assumes every accepted FE plan already carries the new hidden dependencies, but the PR removes the BE-side expansion that older FEs rely on and adds no thrift/version handshake. The immediately prior FE emits the same be_exec_version=11, so its ordinary plans can reach this BE without sequence/map, commit-TSO, or row-binlog helper slots; the BE then silently chooses the wrong MOR winner or fails _init_tso_predicates/init_sequence_map. Retain legacy dependency expansion (with ordinal remapping), or add an explicit plan capability marker before treating the tuple as authoritative.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

不兼容旧FE

@csun5285 csun5285 changed the title [Draft](be) Unify storage reader column ordinals [refactor](be) Unify storage reader column ordinals Aug 10, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

.ann_topn_runtime {},
.condition_cache_digest = parent->get_condition_cache_digest(),
.binlog_scan_type = params.binlog_scan_type,
.start_tso = std::nullopt,

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.

这俩字段没用?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

不需要往下层传递了,这一层就构建出 tso 的pred 了

Comment thread be/src/exec/scan/olap_scanner.cpp Outdated
// Scanner will be executed in a different thread, so we need to clone the context.
VExprContextSPtr context;
RETURN_IF_ERROR(expr_it->second->clone(_state, context));
_virtual_column_exprs[ordinal] = std::move(context);

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.

如果这个_virtual_column_exprs 的key 是columnid,这里直接从0 开始,感觉跟之前的tablet column的id 重合了

olap_scan_local_state->get_topn_filter_source_node_ids(_state, true);
if (!_tablet_reader_params.topn_filter_source_node_ids.empty()) {
_tablet_reader_params.topn_filter_target_node_id =
olap_scan_local_state->parent()->node_id();

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.

这里为啥删掉了

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

没用了

RETURN_IF_ERROR(pair.second->clone(_state, context));
_slot_id_to_virtual_column_expr[pair.first] = context;
for (uint32_t ordinal = 0; auto* slot : _output_tuple_desc->slots()) {
if (slot->get_virtual_column_expr()) {

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.

把这个方法移动到tuple descriptor 里

_tablet_reader_params.tso_predicate_column_id = static_cast<ColumnId>(tso_index);

// The scan-node digest does not contain the per-range TSO bounds.
_tablet_reader_params.condition_cache_digest = 0;

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.

设置成0 是什么含义?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

在这个where 条件下 condition_cache 失效


protected:
const TabletSchema& _schema;
ReadSchemaSPtr _schema;

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.

这个是不是得const?

@csun5285
csun5285 force-pushed the refactor/reader-return-columns branch from aff0dbe to 990e3f8 Compare August 10, 2026 14:42
csun5285 added a commit to csun5285/doris that referenced this pull request Aug 10, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66472

Problem Summary: The reader-schema refactor renamed storage block and schema APIs, but several BE tests still used the old interfaces. The FE translator test also left row-binlog index replicas behind the partition version, and one DATETIMEV2 fixture omitted its scale. Update these test fixtures so the refactored reader code is compiled and exercised correctly.

### Release note

None

### Check List (For Author)

- Test: Unit Test and build
    - ASAN BE and FE build
    - PhysicalPlanTranslatorTest: 13 tests passed
    - Reader-related BE UT: 71 tests passed
    - clang-format and clang-tidy passed
- Behavior changed: No
- Does this need documentation: No
csun5285 added a commit to csun5285/doris that referenced this pull request Aug 10, 2026
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#66472

Problem Summary: Reader schemas can require storage-only columns that are absent from the SQL output, including historical columns used by delete predicates, row-binlog semantic columns, and merge sequence columns. Losing those dependencies can bind predicates to the wrong schema or materialize a row selected without the correct sequence semantics. Preserve and validate those dependencies, disable TopN lazy materialization for sequence-map tables, add focused coverage, and update storage tests to use the explicit storage-block API.

### Release note

Fix hidden storage-column handling for reader schemas, row-binlog scans, historical delete predicates, and TopN lazy materialization.

### Check List (For Author)

- Test:
    - Unit Test: PhysicalPlanTranslatorTest, DeleteHandler tests, ValidateStageTest, VariantRowStoreTest
    - Regression test: test_alter_table_column_with_delete_drop_column_dup_key
    - Build: BE and FE
- Behavior changed: Yes. Hidden storage dependencies are retained and sequence-map TopN lazy materialization is disabled.
- Does this need documentation: No
csun5285 added a commit to csun5285/doris that referenced this pull request Aug 10, 2026
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#66472

Problem Summary: Reader predicates and historical delete columns were still wired through transitional TabletReader-only helpers after read-schema ordinals were unified. Normalize LIKE predicates once in the scanner, preserve per-clone LIKE execution state, remove obsolete FunctionFilter factories, and append dropped delete-predicate columns in every TabletReader and schema-change path so predicate ordinals remain aligned with ReadSchema.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: PhysicalPlanTranslatorTest, DeleteHandler tests, ValidateStageTest, VariantRowStoreTest
    - Regression test: test_alter_table_column_with_delete_drop_column_dup_key
    - Build: BE and FE
- Behavior changed: No. This completes the internal reader schema and predicate ownership refactoring.
- Does this need documentation: No
@csun5285

Copy link
Copy Markdown
Contributor Author

run buildall

@csun5285

Copy link
Copy Markdown
Contributor Author

/review

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

Review result: the full review of all 141 changed paths converged with no new distinct blocking finding, so this review adds zero inline comments. The existing P1 about old-FE/new-BE rolling-upgrade compatibility remains tracked in its current thread and is intentionally not duplicated here; the previously reported lazy-scan slot-preservation omission is fixed at this head.

Critical checkpoint conclusions:

  • Goal and proof: The change replaces sparse tablet-CID read layouts with an ordered ReadSchema whose visible prefix exactly matches caller Blocks, while FE preserves the hidden key, sequence/sequence-map, snapshot, row-binlog, and before-image dependencies that storage needs. The production path and the added BE/FE/result-bearing regression tests are consistent with that goal.
  • Focus and minimality: The diff is broad because the coordinate and Block-construction contract crosses the scanner, rowset, iterator, compaction, schema-change, index, and test layers. The semantic changes are concentrated in schema ownership, slot preservation, read ordinals, and historical-delete resolution; no unrelated behavioral addition survived review.
  • Concurrency: Read schemas are completed during initialization and then consumed through owning/shared references; per-scanner expressions, predicates, and LIKE search scratch are cloned rather than concurrently mutated. No new thread entry, lock ordering, atomic, race, or deadlock concern was introduced.
  • Lifecycle and static initialization: ReadSchemaSPtr ownership extends through lazy segment, rowset, union, and merge iterators, while direct-reader local schemas outlive their iterators. Historical suffix columns live in the owning schema, and no reference cycle, premature release, or cross-TU static-initialization dependency was found.
  • Configuration: No production configuration item or dynamic-update contract was added. FE tests save and restore the global binlog/stream flags they modify.
  • Compatibility: No storage format, persisted metadata, or new thrift field is introduced. The existing rolling-upgrade concern—an older FE does not send the newly authoritative hidden dependency set to this BE—is already covered by the live P1 thread and remains the compatibility conclusion for this checkpoint.
  • Parallel paths: Ordinary and lazy OLAP scans, snapshot wrappers, APPEND_ONLY/MIN_DELTA/DETAIL row binlog, simple sequence and sequence maps, raw binlog TVF, local/cloud schema change, horizontal/vertical compaction, segcompaction, checksum, index builder, historical-row fetch, ANN/inverted-index/virtual-slot paths, and empty/statistics iterators were traced. No stale production coordinate path was found.
  • Conditional logic: Key-merge versus direct/union mode, visible-prefix versus delete-only suffix columns, sequence-map eligibility, single-version TSO replacement, predicate/common-expression/output role selection after zonemap or inverted-index elimination, nullable conversions, zero-row handling, and EOF restoration preserve their documented invariants.
  • Test coverage: Added ReadSchema, descriptor, DeleteHandler, merge/binlog, iterator-role, ANN, translator, and materialization tests cover the changed contracts. Ordered regressions exercise value-only row-binlog projections, hidden sequence-map dependencies, lazy-materialization rejection for sequence maps, and dropped/re-added delete columns across schema changes. No concrete uncovered PR-introduced failure remained.
  • Test results: The changed expected outputs match the reviewed queries and use deterministic ordering. Per the automated review instructions, tests and builds were not run in this review, so no execution result is claimed.
  • Observability: Read-schema/profile labels and iterator-phase counters remain coherent, while merge-contract and initialization errors retain tablet, rowset, version, and schema-width context. No new distributed or silent critical path required an additional metric.
  • Transactions and persistence: The change does not modify EditLog, transaction state, publish ordering, rowset commit protocols, version visibility, or persisted schema encoding. Historical delete predicates continue to bind to their creating rowset schema.
  • Data writes: Writer-side edits select explicit physical storage Blocks; partial update, row-binlog writing, compaction, and schema-change output retain their existing atomic rowset/writer lifecycles and visible Block widths. No new crash window or write-order issue was found.
  • FE/BE variables: Existing tuple slots carry order, UID, type, and nullability into one read-ordinal coordinate system used by predicates, access paths, virtual/ANN expressions, merge comparators, and output projection. No new transmitted variable was added; the old-FE compatibility caveat is the already-tracked exception above.
  • Performance: Exact Block prefixes avoid materializing historical delete-only suffixes, deferred output reads remain lazy, adaptive sizing counts visible columns, and semantic slots are retained only when required. Conservative optimization disables were reviewed and no correctness-affecting or obvious hot-path regression survived.
  • Other safety checks: Status propagation, exception conversion, nullable/constant-column boundaries, merge-contract assertions, and shared-schema mutation timing were reviewed. One row-binlog TSO suspicion was reconstructed against the merge base and dismissed because its complete enabling path predates this PR.

User focus: no additional review focus was provided; the whole PR was reviewed.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29450 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 2383f16e110557c6d269bbb3a2cefb235e5f2670, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17608	4065	4112	4065
q2	2001	336	202	202
q3	10330	1504	833	833
q4	4685	498	336	336
q5	7525	862	551	551
q6	189	177	145	145
q7	748	789	597	597
q8	9355	1664	1622	1622
q9	5233	4070	4080	4070
q10	6730	1637	1363	1363
q11	514	352	329	329
q12	713	568	467	467
q13	18122	3420	2765	2765
q14	264	278	240	240
q15	q16	742	736	674	674
q17	1014	1025	923	923
q18	6664	5628	5555	5555
q19	1348	1299	1115	1115
q20	801	719	605	605
q21	6180	2846	2676	2676
q22	447	382	317	317
Total cold run time: 101213 ms
Total hot run time: 29450 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5089	4652	4780	4652
q2	311	340	219	219
q3	5002	5325	4606	4606
q4	2225	2283	1417	1417
q5	4550	4598	4446	4446
q6	241	191	137	137
q7	1845	1724	1530	1530
q8	2337	2016	2029	2016
q9	7259	6975	6698	6698
q10	4239	4221	3814	3814
q11	513	369	339	339
q12	709	708	498	498
q13	2996	3248	2756	2756
q14	266	286	248	248
q15	q16	658	675	603	603
q17	1241	1213	1199	1199
q18	12035	10979	11684	10979
q19	1084	1077	1070	1070
q20	2182	2177	1912	1912
q21	5467	4639	4487	4487
q22	508	451	430	430
Total cold run time: 60757 ms
Total hot run time: 54056 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 158113 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 2383f16e110557c6d269bbb3a2cefb235e5f2670, data reload: false

query5	4323	589	444	444
query6	477	212	210	210
query7	4842	583	337	337
query8	321	166	151	151
query9	8782	4039	4031	4031
query10	464	375	306	306
query11	5695	2198	2026	2026
query12	150	99	97	97
query13	1257	605	428	428
query14	6092	4438	3948	3948
query14_1	3810	3780	3791	3780
query15	203	193	175	175
query16	982	442	472	442
query17	905	665	528	528
query18	2425	467	333	333
query19	202	188	143	143
query20	102	97	98	97
query21	233	157	132	132
query22	13174	13082	12824	12824
query23	15793	15194	14641	14641
query23_1	14548	14762	14615	14615
query24	7774	1747	1251	1251
query24_1	1275	1237	1218	1218
query25	567	422	344	344
query26	1312	353	210	210
query27	2597	603	368	368
query28	4561	1993	2012	1993
query29	1035	593	470	470
query30	352	266	223	223
query31	1187	1131	1051	1051
query32	104	61	62	61
query33	503	302	237	237
query34	1191	1143	653	653
query35	726	729	623	623
query36	785	777	687	687
query37	159	104	86	86
query38	1842	1766	1677	1677
query39	827	830	793	793
query39_1	793	775	797	775
query40	253	167	143	143
query41	65	65	63	63
query42	91	89	91	89
query43	327	323	284	284
query44	1494	758	757	757
query45	188	180	188	180
query46	1111	1194	690	690
query47	1499	1502	1441	1441
query48	414	402	300	300
query49	593	405	318	318
query50	1078	464	337	337
query51	10842	10690	10554	10554
query52	91	89	76	76
query53	272	284	206	206
query54	300	258	246	246
query55	78	77	69	69
query56	341	316	313	313
query57	1021	1009	914	914
query58	297	265	262	262
query59	1574	1625	1375	1375
query60	329	289	275	275
query61	173	176	173	173
query62	404	321	280	280
query63	236	199	203	199
query64	2999	1135	981	981
query65	3872	3849	3824	3824
query66	1852	489	366	366
query67	20205	20144	19719	19719
query68	3435	1544	1012	1012
query69	412	305	333	305
query70	865	795	781	781
query71	351	341	322	322
query72	3042	2606	2297	2297
query73	870	804	444	444
query74	4697	4491	4295	4295
query75	2382	2337	1970	1970
query76	2317	1149	761	761
query77	353	363	277	277
query78	11204	11206	10562	10562
query79	1375	1144	777	777
query80	881	560	451	451
query81	488	327	280	280
query82	630	177	128	128
query83	380	324	299	299
query84	332	165	128	128
query85	962	596	528	528
query86	368	242	222	222
query87	1993	1961	1834	1834
query88	3774	2768	2790	2768
query89	394	319	285	285
query90	1901	194	185	185
query91	201	188	157	157
query92	64	59	57	57
query93	1617	1460	992	992
query94	605	350	293	293
query95	773	576	479	479
query96	1085	840	356	356
query97	2470	2437	2353	2353
query98	197	199	195	195
query99	732	730	604	604
Total cold run time: 245705 ms
Total hot run time: 158113 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.83 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 2383f16e110557c6d269bbb3a2cefb235e5f2670, data reload: false

query1	0.01	0.01	0.00
query2	0.09	0.04	0.04
query3	0.26	0.13	0.13
query4	1.61	0.14	0.14
query5	0.23	0.25	0.22
query6	1.16	0.79	0.80
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.37	0.30	0.30
query10	0.55	0.54	0.57
query11	0.20	0.14	0.14
query12	0.18	0.14	0.14
query13	0.47	0.47	0.47
query14	1.01	1.01	1.01
query15	0.59	0.59	0.58
query16	0.32	0.33	0.31
query17	1.10	1.06	1.08
query18	0.21	0.20	0.19
query19	2.02	1.98	1.95
query20	0.01	0.02	0.01
query21	15.44	0.21	0.14
query22	4.93	0.06	0.05
query23	16.13	0.31	0.12
query24	3.02	0.44	0.30
query25	0.11	0.06	0.03
query26	0.72	0.20	0.15
query27	0.04	0.03	0.04
query28	3.56	0.81	0.34
query29	12.50	4.02	3.15
query30	0.28	0.15	0.16
query31	2.77	0.56	0.32
query32	3.21	0.58	0.49
query33	3.27	3.28	3.22
query34	15.46	3.95	3.28
query35	3.26	3.22	3.22
query36	0.55	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.14
query41	0.09	0.03	0.03
query42	0.04	0.03	0.02
query43	0.04	0.04	0.04
Total cold run time: 96.26 s
Total hot run time: 23.83 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 81.55% (84/103) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 83.65% (87/104) 🎉
Increment coverage report
Complete coverage report

Issue Number: N/A

Related PR: apache#66432

Problem Summary: Storage readers maintained FE block positions, tablet-schema column IDs, predicate IDs, and delete-predicate columns through parallel mappings. Projection, nested-column pruning, virtual expressions, and row-binlog dependencies could make those mappings diverge. Use one ordered read schema as the reader coordinate, keep expected materialization types alongside physical columns, append storage-only delete-predicate dependencies after FE slots, and preserve required row-binlog scan columns without changing the scan output contract.

Fix inconsistent storage-reader column mappings for projected and row-binlog scans.

- Test:
    - ASAN BE and FE build
    - BE clang-format and format check
    - FE Checkstyle
    - Regression: row_binlog_p0, delete_p0, unique_seq_map_p0, and targeted schema-change/delete/sequence suites
    - Regression: variant_p0 code-related cases passed; one outfile case was blocked by invalid external OSS credentials
- Behavior changed: Yes (reader column identity and row-binlog dependency handling are unified)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66472

Problem Summary: The reader-schema refactor renamed storage block and schema APIs, but several BE tests still used the old interfaces. The FE translator test also left row-binlog index replicas behind the partition version, and one DATETIMEV2 fixture omitted its scale. Update these test fixtures so the refactored reader code is compiled and exercised correctly.

### Release note

None

### Check List (For Author)

- Test: Unit Test and build
    - ASAN BE and FE build
    - PhysicalPlanTranslatorTest: 13 tests passed
    - Reader-related BE UT: 71 tests passed
    - clang-format and clang-tidy passed
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#66472

Problem Summary: Reader schemas can require storage-only columns that are absent from the SQL output, including historical columns used by delete predicates, row-binlog semantic columns, and merge sequence columns. Losing those dependencies can bind predicates to the wrong schema or materialize a row selected without the correct sequence semantics. Preserve and validate those dependencies, disable TopN lazy materialization for sequence-map tables, add focused coverage, and update storage tests to use the explicit storage-block API.

### Release note

Fix hidden storage-column handling for reader schemas, row-binlog scans, historical delete predicates, and TopN lazy materialization.

### Check List (For Author)

- Test:
    - Unit Test: PhysicalPlanTranslatorTest, DeleteHandler tests, ValidateStageTest, VariantRowStoreTest
    - Regression test: test_alter_table_column_with_delete_drop_column_dup_key
    - Build: BE and FE
- Behavior changed: Yes. Hidden storage dependencies are retained and sequence-map TopN lazy materialization is disabled.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#66472

Problem Summary: Reader predicates and historical delete columns were still wired through transitional TabletReader-only helpers after read-schema ordinals were unified. Normalize LIKE predicates once in the scanner, preserve per-clone LIKE execution state, remove obsolete FunctionFilter factories, and append dropped delete-predicate columns in every TabletReader and schema-change path so predicate ordinals remain aligned with ReadSchema.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: PhysicalPlanTranslatorTest, DeleteHandler tests, ValidateStageTest, VariantRowStoreTest
    - Regression test: test_alter_table_column_with_delete_drop_column_dup_key
    - Build: BE and FE
- Behavior changed: No. This completes the internal reader schema and predicate ownership refactoring.
- Does this need documentation: No
Issue Number: None

Related PR: apache#65396

Problem Summary: ReadSchema keeps full physical TabletColumn metadata while its read type may contain a pruned complex-column shape. Aggregate readers previously created reader_replace from the physical type, so pruned Struct blocks could fail type validation. Use the ReadSchema type when constructing reader aggregate functions while preserving the physical-type overload for storage callers. Add the overlapping-segment and aggregate-reader regression coverage from apache#65396. Also initialize the scan-normalization test tuple descriptor required by read-schema ordinal binding.

Fix queries that aggregate pruned complex columns across rowsets.

- Test:
    - ASAN BE build
    - Regression test: fault_injection_p0/test_topn_pruned_struct_overlapping_segments
    - Regression test: schema_change_p0/test_schema_change_unique_mow (3 consecutive runs)
- Behavior changed: Yes. Aggregate readers now bind functions to the materialized read type.
- Does this need documentation: No
@csun5285
csun5285 force-pushed the refactor/reader-return-columns branch from 2383f16 to 4952478 Compare August 11, 2026 05:00
@csun5285

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29454 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 495247871d4fd4089ca750c5e0a7d053dd56a3c8, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17966	4014	4033	4014
q2	2023	339	217	217
q3	10265	1499	820	820
q4	4681	480	337	337
q5	7504	840	550	550
q6	177	170	139	139
q7	757	793	604	604
q8	9328	1523	1561	1523
q9	5405	4172	4132	4132
q10	6731	1636	1382	1382
q11	519	363	331	331
q12	740	595	463	463
q13	18117	3333	2707	2707
q14	259	261	254	254
q15	q16	737	738	659	659
q17	1037	1072	1007	1007
q18	6577	5645	5552	5552
q19	1182	1316	1168	1168
q20	815	668	601	601
q21	5913	2848	2669	2669
q22	464	389	325	325
Total cold run time: 101197 ms
Total hot run time: 29454 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4998	4961	4656	4656
q2	294	319	217	217
q3	4923	5242	4636	4636
q4	2142	2261	1416	1416
q5	4786	4497	4415	4415
q6	239	185	137	137
q7	1892	1682	1492	1492
q8	2381	2051	2028	2028
q9	7270	6808	6764	6764
q10	4235	4208	3751	3751
q11	523	369	344	344
q12	704	711	507	507
q13	2997	3343	2738	2738
q14	273	275	255	255
q15	q16	662	678	595	595
q17	1257	1238	1216	1216
q18	12167	10969	11839	10969
q19	1076	1058	1078	1058
q20	2185	2196	1904	1904
q21	5775	4551	4516	4516
q22	507	482	417	417
Total cold run time: 61286 ms
Total hot run time: 54031 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 158086 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 495247871d4fd4089ca750c5e0a7d053dd56a3c8, data reload: false

query5	4288	617	470	470
query6	469	218	199	199
query7	4908	621	323	323
query8	329	165	149	149
query9	8796	4006	3993	3993
query10	519	358	309	309
query11	5817	2192	1998	1998
query12	152	99	95	95
query13	1240	574	417	417
query14	6056	4334	4015	4015
query14_1	3876	3788	3825	3788
query15	204	203	187	187
query16	988	480	452	452
query17	931	693	562	562
query18	2437	481	336	336
query19	208	188	151	151
query20	105	103	112	103
query21	233	161	137	137
query22	13011	13071	12721	12721
query23	15767	15027	14527	14527
query23_1	14620	14707	14765	14707
query24	7500	1741	1252	1252
query24_1	1256	1260	1206	1206
query25	583	411	343	343
query26	1321	373	211	211
query27	2591	598	385	385
query28	4539	1998	1975	1975
query29	1089	624	467	467
query30	348	265	220	220
query31	1175	1115	1048	1048
query32	108	60	61	60
query33	515	301	234	234
query34	1190	1145	617	617
query35	721	745	626	626
query36	773	783	717	717
query37	155	110	91	91
query38	1824	1770	1677	1677
query39	816	824	797	797
query39_1	788	790	796	790
query40	253	176	145	145
query41	66	66	69	66
query42	94	92	91	91
query43	328	336	287	287
query44	1491	763	744	744
query45	186	171	169	169
query46	1062	1165	704	704
query47	1555	1490	1442	1442
query48	408	409	294	294
query49	586	402	299	299
query50	1090	411	346	346
query51	10691	10499	10341	10341
query52	87	89	74	74
query53	258	283	189	189
query54	298	251	230	230
query55	76	72	72	72
query56	305	306	305	305
query57	1010	1006	912	912
query58	280	252	261	252
query59	1524	1590	1409	1409
query60	344	271	252	252
query61	164	145	152	145
query62	408	317	259	259
query63	232	207	195	195
query64	2885	1156	985	985
query65	3883	3806	3793	3793
query66	1847	485	405	405
query67	20206	19988	19864	19864
query68	3328	1532	1027	1027
query69	425	303	267	267
query70	884	802	784	784
query71	384	328	325	325
query72	3086	2680	2363	2363
query73	852	739	437	437
query74	4632	4499	4304	4304
query75	2360	2349	2003	2003
query76	2340	1158	753	753
query77	348	371	282	282
query78	11188	11123	10558	10558
query79	1359	1231	763	763
query80	730	549	458	458
query81	469	330	286	286
query82	646	174	137	137
query83	389	344	297	297
query84	319	158	134	134
query85	946	579	527	527
query86	327	230	207	207
query87	1970	1916	1828	1828
query88	3755	2766	2734	2734
query89	399	321	284	284
query90	1911	195	192	192
query91	205	191	162	162
query92	62	58	59	58
query93	1608	1582	989	989
query94	558	374	317	317
query95	798	575	470	470
query96	1116	799	340	340
query97	2447	2440	2325	2325
query98	197	191	194	191
query99	741	743	611	611
Total cold run time: 244800 ms
Total hot run time: 158086 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.03 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 495247871d4fd4089ca750c5e0a7d053dd56a3c8, data reload: false

query1	0.01	0.01	0.00
query2	0.09	0.05	0.04
query3	0.25	0.13	0.13
query4	1.61	0.14	0.14
query5	0.24	0.23	0.22
query6	1.16	0.82	0.81
query7	0.04	0.00	0.00
query8	0.05	0.04	0.04
query9	0.38	0.32	0.33
query10	0.57	0.59	0.57
query11	0.18	0.13	0.14
query12	0.18	0.15	0.14
query13	0.47	0.48	0.47
query14	0.99	0.99	1.01
query15	0.60	0.59	0.60
query16	0.33	0.34	0.33
query17	1.11	1.14	1.10
query18	0.23	0.22	0.21
query19	2.06	1.95	1.95
query20	0.02	0.01	0.01
query21	15.44	0.22	0.14
query22	4.91	0.06	0.05
query23	16.11	0.31	0.12
query24	2.97	0.44	0.35
query25	0.10	0.05	0.06
query26	0.74	0.22	0.14
query27	0.04	0.02	0.03
query28	3.50	0.78	0.35
query29	12.48	3.99	3.18
query30	0.27	0.16	0.15
query31	2.77	0.54	0.31
query32	3.22	0.59	0.49
query33	3.11	3.27	3.21
query34	15.43	3.92	3.29
query35	3.22	3.21	3.23
query36	0.55	0.45	0.43
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.03	0.02	0.02
query40	0.17	0.15	0.14
query41	0.09	0.03	0.03
query42	0.04	0.03	0.05
query43	0.04	0.04	0.04
Total cold run time: 95.94 s
Total hot run time: 24.03 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 81.55% (84/103) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 5.99% (10/167) 🎉
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.

3 participants