yiguolei commented on code in PR #66472:
URL: https://github.com/apache/doris/pull/66472#discussion_r3748161996


##########
be/src/exec/scan/olap_scanner.cpp:
##########
@@ -324,51 +326,49 @@ Status OlapScanner::_open_impl(RuntimeState* state) {
     return Status::OK();
 }
 
-// For binlog/snapshot incremental read. Forwards the (start_tso, end_tso] 
range and the TSO
-// column id down to BetaRowsetReader, which builds the comparison predicates 
directly on read
-// options. This bypasses the value/key predicate split in 
TabletReader::_init_conditions_param,
-// guaranteeing the range filter always reaches storage (a correctness 
requirement for MIN_DELTA).
-Status OlapScanner::_init_tso_pushdown() {
+Status OlapScanner::_init_tso_predicates() {
     if (!_start_tso.has_value() && !_end_tso.has_value()) {
         return Status::OK();
     }
 
-    auto& tablet_schema = _tablet_reader_params.tablet_schema;
-    int32_t tso_index = _tablet_reader_params.read_row_binlog ? 
tablet_schema->binlog_tso_col_idx()
-                                                              : 
tablet_schema->commit_tso_col_idx();
+    const auto& read_schema = _tablet_reader_params.read_schema;
+    int32_t tso_ordinal = _tablet_reader_params.read_row_binlog ? 
read_schema->tso_ordinal()
+                                                                : 
read_schema->commit_tso_ordinal();
     const std::string& column_name =
             _tablet_reader_params.read_row_binlog ? BINLOG_TSO_COL : 
COMMIT_TSO_COL;
-    if (tso_index < 0) {
-        return Status::InternalError("Column {} not found in tablet schema 
after append",
-                                     column_name);
+    if (tso_ordinal < 0) {
+        return Status::InvalidArgument(
+                "Column {} must be present in the FE scan schema for 
incremental read",
+                column_name);
     }
 
-    // Push the TSO range down as-is; BetaRowsetReader builds the comparison 
predicates and
-    // injects them straight into read options, so they cannot be dropped by 
the value/key
-    // predicate split in TabletReader::_init_conditions_param.
-    _tablet_reader_params.start_tso = _start_tso;
-    _tablet_reader_params.end_tso = _end_tso;
+    const auto* tso_column = read_schema->column(tso_ordinal);
+    const auto& tso_data_type = read_schema->data_type(tso_ordinal);
+    if (_start_tso.has_value()) {
+        
_tablet_reader_params.predicates.push_back(create_comparison_predicate<PredicateType::GT>(
+                tso_ordinal, tso_column->name(), tso_data_type,
+                Field::create_field<TYPE_BIGINT>(*_start_tso), false));
+    }
+    if (_end_tso.has_value()) {
+        
_tablet_reader_params.predicates.push_back(create_comparison_predicate<PredicateType::LE>(
+                tso_ordinal, tso_column->name(), tso_data_type,
+                Field::create_field<TYPE_BIGINT>(*_end_tso), false));
+    }
 
     // The storage-layer statistics fast path (VStatisticsIterator, picked when
     // push_down_agg_type is COUNT/MINMAX) bypasses SegmentIterator and 
returns raw
     // segment row counts without applying any column predicate. The commit-tso
     // predicate injected above is row-level, so the fast path would both 
miscount
-    // (ignoring commit_tso <= snapshot_tso) and crash on a column-count 
DCHECK when
-    // the tso predicate column is not in return_columns. Disable it here, 
matching
-    // the binlog DETAIL/MIN_DELTA handling.
+    // (ignoring commit_tso <= snapshot_tso). Disable it here, matching the
+    // binlog DETAIL/MIN_DELTA handling.
     _tablet_reader_params.push_down_agg_type_opt = TPushAggOp::NONE;
-
-    // Always carry the tso column id so BetaRowsetReader can build predicates 
on it.
-    // Whether the column must be appended to read_columns (because it is not 
in
-    // return_columns) is decided downstream in BetaRowsetReader.
-    _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;

Review Comment:
   设置成0 是什么含义?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to