zstan commented on code in PR #1418:
URL: https://github.com/apache/ignite-3/pull/1418#discussion_r1049697188


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDynamicParameterTest.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.sql.engine;
+
+import static 
org.apache.ignite.internal.sql.engine.util.SqlTypeUtils.toSqlType;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.time.LocalDate;
+import org.apache.ignite.internal.sql.engine.util.MetadataMatcher;
+import org.apache.ignite.sql.ColumnType;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/** Dynamic parameters checks. */
+public class ItDynamicParameterTest extends AbstractBasicIntegrationTest {
+    private static final Object UNSUPPORTED_SIGN = new Object();
+
+    @Test
+    void testMetadataTypesForDynamicParameters() {
+        int i = 1;
+        for (ColumnType type : ColumnType.values()) {
+            Object param = generateValueByType(i++, type);
+            if (param == UNSUPPORTED_SIGN) {
+                continue;
+            }
+
+            assertQuery("SELECT 
typeof(?)").withParams(param).returns(toSqlType(type)).check();
+            ;
+            assertQuery("SELECT 
?").withParams(param).returns(param).columnMetadata(new 
MetadataMatcher().type(type)).check();
+        }
+    }
+
+    @Test
+    public void testDynamicParameters() {
+        assertQuery("SELECT COALESCE(?, ?)").withParams("a", 
10).returns("a").check();
+        assertQuery("SELECT COALESCE(null, 
?)").withParams(13).returns(13).check();
+        assertQuery("SELECT 
LOWER(?)").withParams("ASD").returns("asd").check();
+        assertQuery("SELECT ?").withParams("asd").returns("asd").check();
+        assertQuery("SELECT ? + ?, LOWER(?) ").withParams(2, 2, 
"TeSt").returns(4, "test").check();
+        assertQuery("SELECT LOWER(?), ? + ? ").withParams("TeSt", 2, 
2).returns("test", 4).check();
+
+        createAndPopulateTable();
+        assertQuery("SELECT name LIKE '%' || ? || '%' FROM person where name 
is not null").withParams("go").returns(true).returns(false)
+                .returns(false).returns(false).check();
+
+        assertQuery("SELECT id FROM person WHERE name LIKE ? ORDER BY id LIMIT 
?").withParams("I%", 1).returns(0).check();
+        assertQuery("SELECT id FROM person WHERE name LIKE ? ORDER BY id LIMIT 
? OFFSET ?").withParams("I%", 1, 1).returns(2).check();
+    }
+
+    // After fix the mute reason need to merge the test with above 
testDynamicParameters
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-18258";)
+    @Test
+    public void testDynamicParameters2() {
+        assertQuery("SELECT POWER(?, ?)").withParams(2, 3).returns(8).check();
+        assertQuery("SELECT SQRT(?)").withParams(4d).returns(2d).check();
+        assertQuery("SELECT ? % ?").withParams(11, 
10).returns(BigDecimal.valueOf(1)).check();
+
+        assertQuery("SELECT id from person where salary<? and 
id>?").withParams(15, 1).returns(2).check();
+    }
+
+    // After fix the mute reason need to merge the test with above 
testDynamicParameters
+    @Disabled("https://issues.apache.org/jira/browse/IGNITE-18345";)
+    @Test
+    public void testDynamicParameters3() {
+        assertQuery("SELECT 
LAST_DAY(?)").withParams(Date.valueOf("2022-01-01")).returns(Date.valueOf("2022-01-31")).check();
+        assertQuery("SELECT 
LAST_DAY(?)").withParams(LocalDate.parse("2022-01-01")).returns(Date.valueOf("2022-01-31")).check();
+    }
+
+    /** Need to test the same query with different type of parameters to cover 
case with check right plans cache work. **/
+    @Test
+    public void testWithDifferentParametersTypes() {

Review Comment:
   why do you use approach with **generateValueByType** in 
testMetadataTypesForDynamicParameters and not use it here ?



##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/util/SqlTypeUtils.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.sql.engine.util;
+
+import org.apache.ignite.sql.ColumnType;
+
+/** Utility class for work with SQL types. */
+public class SqlTypeUtils {
+    /** Converting  from {@code SqlColumnType} type to SQL type name. */

Review Comment:
   not SqlColumnType but ColumnType and possibly need to change java doc



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/ExpressionFactoryImpl.java:
##########
@@ -551,6 +553,18 @@ private String digest(List<RexNode> nodes, RelDataType 
type, boolean biParam) {
                 continue;
             }
 
+            if (node instanceof RexCall) {

Review Comment:
   do we need to fill the same issue for ai-2 ?



##########
modules/api/src/main/java/org/apache/ignite/sql/ColumnMetadata.java:
##########
@@ -51,7 +51,7 @@ public interface ColumnMetadata {
      *
      * @return Value type.
      */
-    SqlColumnType type();
+    ColumnType type();

Review Comment:
   does for now column type is exactly SQL column type ? If no - we need to 
change java doc.



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/ExpressionFactoryImpl.java:
##########
@@ -551,6 +553,18 @@ private String digest(List<RexNode> nodes, RelDataType 
type, boolean biParam) {
                 continue;
             }
 
+            if (node instanceof RexCall) {
+                RexCall call = (RexCall) node;
+                if (!call.operands.isEmpty()) {

Review Comment:
   why we don`t want to rely on RexCall#toString -> 
RexCall#computeDigest(boolean) ?



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