morrySnow commented on code in PR #46003:
URL: https://github.com/apache/doris/pull/46003#discussion_r1897663841


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -407,8 +407,14 @@ public Expression visitUnboundFunction(UnboundFunction 
unboundFunction, Expressi
         Pair<? extends Expression, ? extends BoundFunction> buildResult = 
builder.build(functionName, arguments);
         buildResult.second.checkOrderExprIsValid();
         Optional<SqlCacheContext> sqlCacheContext = Optional.empty();
+        StatementContext statementContext = 
context.cascadesContext.getStatementContext();
+
+        // If it is prepared statement in EXECUTE phase, record 
nonDeterministic info
+        if (ConnectContext.get() != null && ConnectContext.get().getCommand() 
== MysqlCommand.COM_STMT_EXECUTE
+                && !buildResult.second.isDeterministic()) {
+            statementContext.setHasNondeterministicInPreparedStatement(true);
+        }

Review Comment:
   set this flag for all statement or mv this flag out of statement conctext



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java:
##########
@@ -70,14 +70,15 @@ public void run(ConnectContext ctx, StmtExecutor executor) 
throws Exception {
         LogicalPlanAdapter planAdapter = new 
LogicalPlanAdapter(prepareCommand.getLogicalPlan(), executor.getContext()
                 .getStatementContext());
         executor.setParsedStmt(planAdapter);
-        // If it's not a short circuit query or schema version is 
different(indicates schema changed),
-        // need to do reanalyze and plan
+        // If it's not a short circuit query or schema version is 
different(indicates schema changed) or
+        // has nondeterministic functions in statement, then need to do 
reanalyze and plan
         boolean isShortCircuit = 
executor.getContext().getStatementContext().isShortCircuitQuery();
         boolean hasShortCircuitContext = 
preparedStmtCtx.shortCircuitQueryContext.isPresent();
         boolean schemaVersionMismatch = hasShortCircuitContext
                     && 
preparedStmtCtx.shortCircuitQueryContext.get().tbl.getBaseSchemaVersion()
                     != 
preparedStmtCtx.shortCircuitQueryContext.get().schemaVersion;
-        boolean needAnalyze = !isShortCircuit || schemaVersionMismatch || 
!hasShortCircuitContext;
+        boolean needAnalyze = !isShortCircuit || schemaVersionMismatch || 
!hasShortCircuitContext
+                        || 
executor.getContext().getStatementContext().hasNondeterministicInPreparedStatement();

Review Comment:
   does it work? ExpressionAnalyzer be called in nerieds' analyzer. 
ExpressionAnalyzer should not be called when come here. so i don't think 
hasNondeterministicInPreparedStatement will be set correctly.



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