2828import org .apache .doris .catalog .FunctionRegistry ;
2929import org .apache .doris .catalog .KeysType ;
3030import org .apache .doris .catalog .OlapTable ;
31- import org .apache .doris .catalog .OlapTableWrapper ;
3231import org .apache .doris .catalog .Partition ;
3332import org .apache .doris .catalog .RowBinlogTableWrapper ;
3433import org .apache .doris .catalog .SchemaTable ;
@@ -242,9 +241,8 @@ private LogicalPlan makeOlapScan(TableIf table, UnboundRelation unboundRelation,
242241 LogicalOlapScan scan ;
243242 List <Long > partIds = getPartitionIds (table , unboundRelation , qualifier );
244243 List <Long > tabletIds = unboundRelation .getTabletIds ();
245- boolean isChangeRead = unboundRelation .getScanParams () != null
246- && unboundRelation .getScanParams ().incrementalRead ();
247- if (isChangeRead ) {
244+ StreamScanType changeScanType = checkChangeScanCondition ((OlapTable ) table , unboundRelation .getScanParams ());
245+ if (changeScanType != null ) {
248246 table = new RowBinlogTableWrapper ((OlapTable ) table );
249247 } else if (unboundRelation .getScanParams () != null ) {
250248 unboundRelation .getScanParams ().validateOlapTable ();
@@ -265,7 +263,7 @@ private LogicalPlan makeOlapScan(TableIf table, UnboundRelation unboundRelation,
265263 throw new AnalysisException ("Table " + olapTable .getName ()
266264 + " doesn't have materialized view " + indexName .get ());
267265 }
268- if (isChangeRead && olapTable .getBaseIndexId () != indexId ) {
266+ if (changeScanType != null && olapTable .getBaseIndexId () != indexId ) {
269267 throw new AnalysisException ("Change read is not supported on non-base index " + indexName .get ());
270268 }
271269 if (unboundRelation .getTableSnapshot ().isPresent () && olapTable .getBaseIndexId () != indexId ) {
@@ -291,15 +289,13 @@ private LogicalPlan makeOlapScan(TableIf table, UnboundRelation unboundRelation,
291289 // This tabletIds is set manually, so need to set specifiedTabletIds
292290 scan = scan .withManuallySpecifiedTabletIds (tabletIds );
293291 }
294- if (isChangeRead ) {
292+ if (changeScanType != null ) {
295293 if (cascadesContext .getStatementContext ().isHintForcePreAggOn ()) {
296294 throw new AnalysisException (
297295 "PREAGGOPEN hint is not supported on @incr (change-read) scans." );
298296 }
299- StreamScanType scanType = checkChangeScanCondition (((OlapTableWrapper ) table ).getOriginTable (),
300- unboundRelation .getScanParams ());
301- return checkAndAddChangeScanFilter (scan , scanType , parseTimestampRange (unboundRelation .getScanParams ()),
302- false );
297+ return checkAndAddChangeScanFilter (scan , changeScanType ,
298+ parseTimestampRange (unboundRelation .getScanParams ()), false );
303299 }
304300 // Time-travel (FOR VERSION/TIME AS OF): wrap the scan with a __DORIS_COMMIT_TSO_COL__
305301 // predicate (dup) or a base/binlog union (mow).
@@ -647,10 +643,11 @@ private Optional<LogicalPlan> handleMetaTable(TableIf table, UnboundRelation unb
647643
648644 private StreamScanType checkChangeScanCondition (OlapTable olapTable , TableScanParams scanParams )
649645 throws AnalysisException {
646+ if (scanParams == null || !scanParams .incrementalRead ()) {
647+ return null ;
648+ }
650649 if (!olapTable .needRowBinlog ()) {
651- throw new AnalysisException ("INCR query requires ROW binlog enabled on base table "
652- + "(PROPERTIES('binlog.enable'='true','binlog.format'='ROW')). "
653- + "Table " + olapTable .getQualifiedName () + " doesn't enable row binlog." );
650+ throw new AnalysisException ("INCR query requires ROW binlog enabled on base table." );
654651 }
655652 HashSet <String > keys = new HashSet (scanParams .getMapParams ().keySet ());
656653 keys .remove (OlapScanNode .OLAP_INCREMENT_TYPE );
0 commit comments