lowka commented on code in PR #2857:
URL: https://github.com/apache/ignite-3/pull/2857#discussion_r1424071712


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/IgniteSqlValidator.java:
##########
@@ -119,14 +126,18 @@ public class IgniteSqlValidator extends SqlValidatorImpl {
         HUMAN_READABLE_ALIASES_FOR = Collections.unmodifiableSet(kinds);
     }
 
-    /** Dynamic parameter values. */
-    private final Object[] dynamicParamValues;
+    /** Dynamic parameters state. */
+    private final Map<Integer, DynamicParamState> dynamicParameters;
 
-    /** Dynamic parameters SQL AST nodes for invariant checks - see {@link 
#validateInferredDynamicParameters()}. */
-    private final SqlDynamicParam[] dynamicParamNodes;
+    /**
+     * The same dynamic parameter can be used in the same SQL tree multiple 
types after a rewrite.
+     * (E.g. COALESCE(?0, ?1) is rewritten into CASE WHEN ?0 IS NOT NULL THEN 
?0 ELSE ?1 END)
+     * We store them to check that every i-th parameter has the same type.
+     */
+    private final IdentityHashMap<SqlDynamicParam, SqlDynamicParam> 
dynamicParamNodes = new IdentityHashMap<>();

Review Comment:
   No, we can't. As using int -> sql node here defeats the purpose of this map. 
(see the comment)
   Because Validator rewrites COALESCE into a case expressions that uses the 
same parameter multiple times. 
   



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

Reply via email to