Repository navigation
[feat](dynamic table) support table stream part 4: support snapshot read - #64776
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
9cc4454 to
6ea0bc7
Compare
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 29442 ms |
TPC-DS: Total hot run time: 173308 ms |
ClickBench: Total hot run time: 25.14 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 29321 ms |
TPC-DS: Total hot run time: 172138 ms |
ClickBench: Total hot run time: 25.3 s |
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
FE UT Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 29736 ms |
TPC-DS: Total hot run time: 171912 ms |
e60ecf6
|
run buildall |
There was a problem hiding this comment.
Automated review found two remaining correctness issues on the current head. I verified the earlier qualifier/test-compile candidates were fixed in cb50856 and reran subagent convergence for the reduced comment set. Validation was static only in this runner because the Doris thirdparty/protoc dependencies are not installed.
|
Codex automated review failed and did not complete. Error: Codex completed, but no new pull request review was submitted for the current head SHA. Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
TPC-H: Total hot run time: 30156 ms |
TPC-DS: Total hot run time: 172924 ms |
ClickBench: Total hot run time: 25.32 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
/review |
|
Codex automated review failed and did not complete. Error: Your access token could not be refreshed because your refresh token was already used. Please log out and sign in again. Please inspect the workflow logs and rerun the review after the underlying issue is resolved. |
|
/review |
|
skip buildall |
There was a problem hiding this comment.
Completed the subagent-assisted review pass for this PR.
I do not have additional non-duplicate inline findings to submit. The issues that looked actionable in this pass are already covered by existing review threads, including stream normalization in CTEs, time-based visibility gaps, analyzed-plan stream offset extraction, commit-TSO compatibility/inherited-config boundaries, constant-column reader caching, RANDOM AGG_KEYS compensation, and regression-test style/cleanup.
Focus: no additional user-provided review focus was supplied.
Validation limits: static review only. This checkout is missing .worktree_initialized, thirdparty/installed, and the FE/BE build prerequisites, so I did not run build or tests.
|
Tracked by #65418 as part of the row binlog, Table Stream, and MTMV incremental-computation work. |
…an semantics (#70631) ### Background Segment scans remove predicates that zone maps prove always true. A non-output column may then use a placeholder instead of being read, so scan planning must accurately describe whether storage fully handles its predicates. ### What problem does this PR solve? Issue Number: None Related PR: #64776 (snapshot wrapper path), #65859 (Cloud wrapper path) PR Type: Bugfix Problem Summary: Constant equality predicates were never recognized as always true, so even `__DORIS_DELETE_SIGN__ = 0` could force MOW ANN Top-N queries to use brute-force scanning. Recognize non-negated equality when both zone-map bounds equal the predicate value. This also exposes an existing snapshot-planning inconsistency: `OlapTableWrapper` reports a real MOW table as non-MOW, leaving a residual value predicate above storage. If the newly resolved equality lets storage skip that column, the residual predicate can reject placeholder values and return an incorrect empty result. Preserve the origin table's MOW flag for UNIQUE_KEYS wrappers, while keeping DUP_KEYS changelog wrappers non-MOW. ### Details - **Frequency:** Constant equality predicates on segments; the wrong-result interaction affects MOW snapshot scans whose equality-filtered column is absent from the projection. Cloud full-refresh scans also use this wrapper. - **Root cause:** Equality was absent from `ComparisonPredicateBase::is_always_true()`, and `OlapTableWrapper` did not preserve the base table's MOW property. The latter made the scan operator and tablet reader disagree about merge semantics. - **Why existing tests missed it:** ANN results can be correct through brute-force fallback. Existing wrapper tests did not check MOW identity, and ordinary non-Cloud COMPLETE refreshes do not take the affected Cloud wrapper path. - **Fix:** Use row-evaluation equality semantics for both zone-map bounds, retaining NULL rejection and negation checks. Delegate MOW metadata only for UNIQUE_KEYS wrappers; add MOW/MOR/changelog unit coverage and a non-Cloud snapshot regression with a filter-only boolean column. - **Other paths and branches:** Keep the existing Cloud MV regression and expected rows intact. The snapshot regression compares the filter-only projection with projecting the boolean and with skip-read disabled. No protocol, storage-format, delete-bitmap or write-path changes. ### Testing Local validation on master base `de48fa225e4` with the EQ change and the wrapper repair: - BE ASAN and FE builds passed; after reproducing the snapshot error, rebuilding/restarting only FE with the wrapper repair restored the correct three rows while keeping the same BE binary and EQ optimization. - `run-fe-ut.sh --run org.apache.doris.catalog.OlapTableWrapperTest`: 7 tests passed; FE Checkstyle passed. - `mtmv_p0/ivm/test_ivm_union_delete_same_base`: passed in non-Cloud mode. - `table_stream_p0/test_olap_table_stream_snapshot_mow_predicate`: passed with script-generated expected output. The equivalent minimal query returned an empty result before the wrapper repair and three rows afterward with skip-read enabled. Earlier validation of the unchanged BE equality implementation: `BlockColumnPredicateTest.*` (20 tests), `ann_index_p0/ann_index_on_mow`, clang-format 16, header hygiene and clang-tidy passed. A synthetic MOW ANN profile changed from 0 index searches / 1 fallback / 10,000 rows read to 1 index search / 0 fallbacks / 10 rows read with identical results; this verifies index selection rather than production latency or recall. The original Cloud-mode CI failure has not been rerun locally in a Cloud deployment; its existing result assertions are preserved for CI validation. ### Release note Avoid unnecessary ANN brute-force fallback for segment-wide constant equality predicates, and preserve MOW semantics in snapshot wrappers to prevent incorrect empty query results when predicate columns are skipped. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Partially verified: local unit/build/regression checks passed; Cloud-mode CI validation pending. ### AI Disclosure - Tool: Codex - Generated: Implementation, tests and PR description. - Human review: Author reviewed the equality pruning logic and directed the wrapper investigation and repair; final additions await author review.
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #57921
Problem Summary:
This PR adds snapshot-oriented read support for OLAP table streams.
Before this change, table streams mainly supported normal incremental consumption and
table@incr()queries. Incremental refresh workflows also need a stable full snapshot that matches a stream consumption point, for example when joining the delta of one table with the snapshot of another table. Full refresh workflows also need a way to read the current full table and advance stream offsets to the latest visible position.This PR introduces the following capabilities:
stream@snapshot()returns the base-table snapshot corresponding to the already consumed per-partition stream offsets. It does not advance stream offsets.stream@reset()returns the current full visible table snapshot and advances stream offsets to the current position when used byINSERT ... SELECT.FOR VERSION AS OF <tso>andFOR TIME AS OF <time>read a table snapshot at the target historical TSO/time.table@incr()continues to read incremental data in a specified time range, with the visibility waiting logic fixed byTimeBasedChangeVisibleWaiter.The implementation keeps stream offsets per partition. FE records
(prev, next]TSO ranges for each partition, rewrites stream scans into base-table snapshot scans or row-binlog scans, and passes partition-levelstart_tso/end_tsointo scan ranges. BE converts these ranges into TSO predicates on eitherDORIS_BINLOG_TIMESTAMPorDORIS_COMMIT_TSO_COL.For snapshot and time-travel reads, changed partitions are reconstructed from the current base table plus row-binlog before-images:
This PR also adds BE support for predicate-only hidden TSO columns, commit-TSO schema propagation, constant column readers for read-time-filled hidden columns, and correctness fixes around binlog merge scans and TSO predicate pushdown.
Release note
Support OLAP table stream snapshot/reset reads and table time-travel snapshot reads.
Check List (For Author)
Covered by table stream and time-travel regression tests, including snapshot, reset, mixed historical/incremental consumption, comprehensive stream query cases, and DUP/MOW time-travel cases.
Covered by FE/BE unit tests for stream offset update logic, insert consumption extraction, table stream plan explanation, time-based visibility waiting, min-delta block reading, constant column iteration, segment iterator TSO predicates, and tablet schema commit-TSO propagation.
Behavior changed:
Does this need documentation?
Feature Semantics
Supported Stream Tables
Only row-binlog-enabled MOW tables and DUP tables can create table streams.
MIN_DELTAstreams are supported only for DUP tables and MOW tables withbinlog.need_historical_value = true.Stream Properties
typeMIN_DELTA,APPEND_ONLYMIN_DELTAreturns net changes;APPEND_ONLYreturns insert-only changes. Default:MIN_DELTA.show_initial_rowstrue,falsefalse.Query Forms
SELECT ... FROM streamSELECTdoes not advance;INSERT ... SELECTadvances after commitSELECT ... FROM stream@snapshot()SELECT ... FROM stream@reset()INSERT ... SELECTSELECT ... FROM table@incr(...)FOR VERSION AS OF <tso>/FOR TIME AS OF <time>Functional Examples
1. Create A Table Stream
2. Consume Incremental Stream Changes
Plain
SELECTcan inspect stream output without advancing the offset.INSERT ... SELECTconsumes the stream and advances offsets only after the transaction commits successfully.3. Read The Snapshot At Consumed Stream Offsets
stream@snapshot()returns base-table columns only. Hidden stream columns are not exposed in the snapshot output.This is useful when an incremental refresh needs the stable snapshot side of a join.
4. Reset A Stream For Full Refresh
stream@reset()returns the current full table snapshot. When it is used byINSERT ... SELECT, the stream offset is advanced to the current latest position.5. Read Table Incremental Changes By Time Range
table@incr()reads row-binlog changes by timestamp range.incrementTypecan beDETAIL,APPEND_ONLY, orMIN_DELTA.When no explicit range is required, callers can still use the default incremental read form.
6. Query Historical Table Snapshots
Read a table snapshot by TSO:
Read a table snapshot by time:
Implementation Notes
outputUpdateMapas(prev, next).NormalizeOlapTableStreamScansplits table stream reads into historical/base-table scans and incremental row-binlog scans.StreamConsumptionInfoExtractorfinds stream scans in analyzed insert plans, skips snapshot scans, and attaches offset update information to the insert transaction.prevbefore commit. If another transaction has already consumed the same stream partition, the current transaction fails instead of advancing stale offsets.(start_tso, end_tso]predicates into storage scans at tablet-scan-range granularity.DORIS_BINLOG_TIMESTAMP; for base-table snapshot/time-travel scans, BE usesDORIS_COMMIT_TSO_COL.