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


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/DynamicParametersTest.java:
##########
@@ -283,12 +636,62 @@ public Stream<DynamicTest> testMergeFull() {
         );
     }
 
+    /**
+     * Dynamic parameters in LIMIT / OFFSET.
+     */
+    @TestFactory
+    public Stream<DynamicTest> testLimitOffset() {
+        Consumer<StatementChecker> setup = (checker) -> {
+            checker.table("t1", "c1", NativeTypes.INT32);
+        };
+
+        return Stream.of(
+                checkStatement(setup)
+                        .sql("SELECT * FROM t1 LIMIT ?", 1)
+                        .parameterTypes(nullable(NativeTypes.INT32))
+                        .ok(),
+
+                checkStatement(setup)
+                        .sql("SELECT * FROM t1 OFFSET ?", 1)
+                        .parameterTypes(nullable(NativeTypes.INT32))
+                        .ok(),
+
+                checkStatement(setup)
+                        .sql("SELECT * FROM t1 LIMIT ?", Unspecified.UNKNOWN)
+                        .parameterTypes(nullable(NativeTypes.INT32))
+                        .ok(),
+
+                checkStatement(setup)
+                        .sql("SELECT * FROM t1 OFFSET ?", Unspecified.UNKNOWN)
+                        .parameterTypes(nullable(NativeTypes.INT32))
+                        .ok(),
+
+                checkStatement(setup)
+                        .sql("SELECT * FROM t1 LIMIT ?", "a")
+                        .parameterTypes(nullable(NativeTypes.INT32))
+                        .fails("Incorrect type of a dynamic parameter#0 
expected <INTEGER> but got <VARCHAR"),
+
+                checkStatement(setup)
+                        .sql("SELECT * FROM t1 OFFSET ?", "a")
+                        .parameterTypes(nullable(NativeTypes.INT32))
+                        .fails("Incorrect type of a dynamic parameter#0 
expected <INTEGER> but got <VARCHAR")
+        );
+    }
+
     /**
      * Function calls.
      */
     @TestFactory
     public Stream<DynamicTest> testFunction() {
         return Stream.of(
+                checkStatement()
+                        .sql("SELECT SUBSTRING(?, 1)", Unspecified.UNKNOWN)
+                        .fails("Ambiguous operator SUBSTRING(<UNKNOWN>, 
<INTEGER>)"),

Review Comment:
   Why does it fail, but a "nested call" is ok?



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