@@ -144,11 +144,20 @@ protected void runBeforeAll() throws Exception {
144144 + "'enable_unique_key_merge_on_write' = 'false',"
145145 + "'sequence_mapping.s1' = 'v1',"
146146 + "'sequence_mapping.s2' = 'v2');" );
147+ // Bump the base table with a real (positive) tso before creating the stream so that the
148+ // stream records a positive consumption offset at creation time; hasConsumedData() only
149+ // treats a positive offset as a real baseline, otherwise every partition would be pruned out
150+ // of the snapshot scan.
151+ Database database = (Database ) Env .getCurrentInternalCatalog ().getDbOrMetaException ("test_db" );
152+ OlapTable binlogScanSchemaTable =
153+ (OlapTable ) database .getTableOrMetaException ("binlog_scan_schema_t" );
154+ bumpPartitionsAndReplicas (binlogScanSchemaTable , 2L , 100L );
147155 createTable ("create stream test_db.binlog_scan_schema_stream "
148156 + "on table test_db.binlog_scan_schema_t properties('type' = 'append_only')" );
149- Database database = (Database ) Env .getCurrentInternalCatalog ().getDbOrMetaException ("test_db" );
150- bumpPartitionsAndReplicas (
151- (OlapTable ) database .getTableOrMetaException ("binlog_scan_schema_t" ), 2L );
157+ // Advance the base table tso again after the stream is created so the partition has new data
158+ // beyond the recorded consumption offset, driving the snapshot scan down the rebuild path
159+ // (base scan wrapped in OlapTableWrapper unioned with the binlog before-image).
160+ bumpPartitionsAndReplicas (binlogScanSchemaTable , 3L , 200L );
152161 createTable ("create table test_db.t_topn_lazy(c1 int, c2 int, c3 int) "
153162 + "duplicate key(c1) distributed by hash(c1) buckets 1 "
154163 + "properties('replication_num' = '1', 'light_schema_change' = 'true');" );
@@ -544,10 +553,10 @@ private List<OlapScanNode> getOlapScanNodes(String sql) throws Exception {
544553 return scanNodes ;
545554 }
546555
547- private static void bumpPartitionsAndReplicas (OlapTable table , long newVersion ) {
556+ private static void bumpPartitionsAndReplicas (OlapTable table , long newVersion , long tso ) {
548557 for (Partition partition : table .getPartitions ()) {
549558 long timestamp = System .currentTimeMillis ();
550- partition .setVisibleVersionAndTime (newVersion , timestamp , timestamp );
559+ partition .setVisibleVersionAndTime (newVersion , timestamp , tso );
551560 partition .setNextVersion (newVersion + 1 );
552561 for (MaterializedIndex index : partition .getMaterializedIndices (IndexExtState .VISIBLE , true )) {
553562 for (Tablet tablet : index .getTablets ()) {
0 commit comments