yujun777 commented on code in PR #63850:
URL: https://github.com/apache/doris/pull/63850#discussion_r3361340581


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java:
##########
@@ -295,17 +297,28 @@ public AbstractInsertExecutor initPlan(ConnectContext 
ctx, StmtExecutor stmtExec
 
             List<ScanNode> tableStreamScanNodes =
                     buildResult.planner.getScanNodes().stream()
-                            .filter(s -> s.getTableIf() instanceof 
OlapTableStreamWrapper).collect(Collectors.toList());
+                            .filter((s -> (s.getTableIf() instanceof 
OlapTableStreamWrapper

Review Comment:
   The concrete NPE path is:
   
   1. `INSERT INTO target SELECT ... FROM base_table@incr(...)` builds a 
base-table change scan in `BindRelation` with `new 
RowBinlogTableWrapper(olapTable)`. This constructor does not set a parent 
stream, so `RowBinlogTableWrapper.getParent()` is `null`.
   2. The scan is incremental, so this filter also collects it into 
`tableStreamScanNodes` even though it is not a table-stream consumption scan.
   3. In the loop below, line 320 assigns `wrapper = ((RowBinlogTableWrapper) 
scanNode.getTableIf()).getParent()`, which is `null` for `base_table@incr(...)`.
   4. The next use of `wrapper`, e.g. `wrapper.getStreamDbId()` / 
`wrapper.getStreamId()`, will NPE.
   
   So the trigger is an insert-select whose source is a pure base table 
`@incr(...)` change query. That read should not update any stream offset, and 
should not be included in this table-stream offset update path.



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