eldenmoon commented on code in PR #35823:
URL: https://github.com/apache/doris/pull/35823#discussion_r1635989433


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java:
##########
@@ -65,8 +69,26 @@ public void run(ConnectContext ctx, StmtExecutor executor) 
throws Exception {
         LogicalPlanAdapter planAdapter = new 
LogicalPlanAdapter(prepareCommand.getLogicalPlan(), executor.getContext()
                 .getStatementContext());
         executor.setParsedStmt(planAdapter);
-        // execute real statement
-        executor.execute();
+        // If it's not a short circuit query or schema version is 
different(indicates schema changed),
+        // need to do reanalyze and plan
+        boolean needAnalyze = 
!executor.getContext().getStatementContext().isShortCircuitQuery()
+                || (preparedStmtCtx.shortCircuitQueryContext.isPresent()
+                    && 
preparedStmtCtx.shortCircuitQueryContext.get().tbl.getBaseSchemaVersion()
+                != 
preparedStmtCtx.shortCircuitQueryContext.get().schemaVersion);
+        if (needAnalyze) {
+            // execute real statement
+            preparedStmtCtx.shortCircuitQueryContext = Optional.empty();
+            statementContext.setShortCircuitQueryContext(null);
+            executor.execute();
+            if 
(executor.getContext().getStatementContext().isShortCircuitQuery()) {
+                // cache short-circuit plan
+                preparedStmtCtx.shortCircuitQueryContext = Optional.of(
+                        new ShortCircuitQueryContext(executor.planner(), 
(Queriable) executor.getParsedStmt()));

Review Comment:
   not cache planner, but need cache the data from palnner



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