hello-stephen commented on code in PR #71160:
URL: https://github.com/apache/doris/pull/71160#discussion_r4737702384


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -1483,6 +1490,38 @@ public LogicalPlan 
visitInsertIntoTVF(InsertIntoTVFContext ctx) {
         return withExplain(command, ctx.explainContext);
     }
 
+    // VALUES command selection happens before binding. In particular, a CAST 
of
+    // CURRENT_TIMESTAMP(6) has no source type yet. Keep the structural 
restrictions of
+    // Expression.isConstant(), but defer type-dependent determinism until 
analysis.
+    private static boolean isConstantForTransactionValues(Expression 
expression) {
+        if (expression instanceof AggregateFunction
+                || expression instanceof Lambda
+                || expression instanceof MaxValue
+                || expression instanceof OrderExpression
+                || expression instanceof Properties
+                || expression instanceof SubqueryExpr
+                || expression instanceof UnboundVariable
+                || expression instanceof Variable
+                || expression instanceof VariableDesc
+                || expression instanceof WindowExpression
+                || expression instanceof WindowFrame
+                || expression instanceof TableGeneratingFunction) {
+            return false;
+        }
+        if (expression instanceof LeafExpression) {
+            return expression instanceof Literal;
+        }
+        try {
+            if (!expression.isDeterministic()) {
+                return false;
+            }
+        } catch (UnboundException e) {

Review Comment:
   [P1] Revalidate deferred TIME-to-date casts before batching
   
   For `t(id INT, v VARCHAR(100))`, consider `BEGIN; INSERT INTO t VALUES (1, 
CAST(CAST(SEC_TO_TIME(1) AS DATETIME) AS STRING)); COMMIT;`. The inner cast's 
source is unbound here, so this catch admits it into 
`BatchInsertIntoTableCommand`. After binding and FE folding, the reduced 
project is:
   
   ```text
   OneRowRelation
     Alias(Cast_STRING(Cast_DATETIME(TimeV2Literal("00:00:01"))))
   ```
   
   `Cast.isDeterministic()` is now false for the TIME-to-DATETIME conversion, 
so `FoldConstantRuleOnFE.preProcess()` leaves that cast unevaluated; the outer 
cast also cannot fold. However, `InsertUtils.getRowStringValue()` strips every 
`Cast` and sends only `00:00:01`, silently storing a time-only string instead 
of the datetime text containing the query date. The default fast analyzer never 
revalidates the deferred check. Please reject or reroute casts that fail this 
check after binding, or evaluate them before serialization, and add a 
stored-value regression using a function that returns TIME. The new negative 
test only covers a syntactically known TIME source.



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