TsukiokaKogane commented on code in PR #62453:
URL: https://github.com/apache/doris/pull/62453#discussion_r3085811996


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java:
##########
@@ -285,6 +296,44 @@ public AbstractInsertExecutor initPlan(ConnectContext ctx, 
StmtExecutor stmtExec
                 return insertExecutor;
             }
 
+            List<ScanNode> tableStreamScanNodes =
+                    buildResult.planner.getScanNodes().stream()
+                            .filter(s -> s.getTableIf() instanceof 
OlapTableStreamWrapper).collect(Collectors.toList());
+
+            if (!tableStreamScanNodes.isEmpty()) {
+                // stream id -> <partition id, offset>
+                Map<Pair<Long, Long>, AbstractTableStreamUpdate> 
distinctUpdate =
+                        new HashMap<>(tableStreamScanNodes.size());
+                for (ScanNode scanNode : tableStreamScanNodes) {
+                    // only support OlapScanNode currently
+                    Preconditions.checkArgument(scanNode instanceof 
OlapScanNode);
+                    OlapScanNode olapScanNode = (OlapScanNode) scanNode;
+                    OlapTableStreamWrapper wrapper = (OlapTableStreamWrapper) 
scanNode.getTableIf();
+                    if (!distinctUpdate.containsKey(
+                            Pair.of(wrapper.getStreamDbId(), 
wrapper.getStreamId()))) {
+                        distinctUpdate.put(Pair.of(wrapper.getStreamDbId(), 
wrapper.getStreamId()),
+                                new OlapTableStreamUpdate());
+                    }
+                    distinctUpdate.get(Pair.of(wrapper.getStreamDbId(), 
wrapper.getStreamId()))
+                                    .merge(olapScanNode.getStreamUpdate());
+                }
+                List<TableStreamUpdateInfo> infos = new 
ArrayList<>(distinctUpdate.size());
+                distinctUpdate.forEach((key, value) -> infos.add(new 
TableStreamUpdateInfo(key.first,
+                        key.second, value)));
+                // put offset into executor
+                insertExecutor.setStreamUpdateInfos(infos);
+                insertExecutor.registerListener(new InsertExecutorListener() {
+                    @Override
+                    public void beforeComplete(AbstractInsertExecutor 
insertExecutor, StmtExecutor executor,

Review Comment:
   do not support cloud yet



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