You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/12/28 10:26:42 UTC

[GitHub] [ignite-3] ygerzhedovich commented on a diff in pull request #1476: IGNITE-18442 Sql. JOIN with DISTINCT FROM fails.

ygerzhedovich commented on code in PR #1476:
URL: https://github.com/apache/ignite-3/pull/1476#discussion_r1058245432


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItJoinTest.java:
##########
@@ -784,34 +790,66 @@ public void testNatural(JoinType joinType) {
         //    .check();
     }
 
-    protected QueryChecker assertQuery(String qry, JoinType joinType) {
-        return AbstractBasicIntegrationTest.assertQuery(qry.replace("select", "select "
-            + Arrays.stream(joinType.disabledRules).collect(Collectors.joining("','", "/*+ DISABLE_RULE('", "') */"))));
-    }
+    /** Check IS NOT DISTINCT execution correctness and IndexSpool presence. */
+    @ParameterizedTest(name = "join algo : {0}, index present: {1}")
+    @MethodSource("joinTypes")
+    @WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
+    public void testIsNotDistinctFrom(JoinType joinType, boolean indexScan) {
+        if (indexScan) {
+            // TODO: https://issues.apache.org/jira/browse/IGNITE-18468 Index scan eventually return partial data.
+            return;
+        }
 
-    enum JoinType {
-        NESTED_LOOP(
-            "CorrelatedNestedLoopJoin",
-            "JoinCommuteRule",
-            "MergeJoinConverter"
-        ),
-
-        MERGE(
-            "CorrelatedNestedLoopJoin",
-            "JoinCommuteRule",
-            "NestedLoopJoinConverter"
-        ),
-
-        CORRELATED(
-            "MergeJoinConverter",
-            "JoinCommuteRule",
-            "NestedLoopJoinConverter"
-        );
+        try {
+            sql("CREATE TABLE t11(i1 INTEGER, i2 INTEGER)");
+
+            if (indexScan) {
+                sql("CREATE INDEX t11_idx ON t11(i1)");
+            }
+
+            sql("INSERT INTO t11 VALUES (1, null), (2, 2), (null, 3), (3, null), (5, null)");
+
+            sql("CREATE TABLE t22(i3 INTEGER, i4 INTEGER)");
+
+            if (indexScan) {
+                sql("CREATE INDEX t22_idx ON t22(i3)");
+            }
+
+            sql("INSERT INTO t22 VALUES (1, 1), (2, 2), (null, 3), (4, null), (5, null)");
+
+            String sql = "SELECT i1, i4 FROM t11 JOIN t22 ON i1 IS NOT DISTINCT FROM i3";
+
+            assertQuery(sql, joinType, indexScan ? "LogicalTableScanConverterRule" : null)
+                    .matches(joinType == CORRELATED ? QueryChecker.containsSubPlan("IgniteHashIndexSpool")
+                            : QueryChecker.matches("(?i).*IS NOT DISTINCT.*"))
+                    .matches(indexScan ? QueryChecker.containsIndexScan("PUBLIC", "T11") :
+                            QueryChecker.containsTableScan("PUBLIC", "T11"))
+                    .returns(1, 1)
+                    .returns(2, 2)
+                    .returns(5, null)
+                    .returns(null, 3)
+                    .check();
+
+            sql = "SELECT i1, i4 FROM t11 JOIN t22 ON i1 IS NOT DISTINCT FROM i3 AND i2 = i4";
+
+            assertQuery(sql, joinType, indexScan ? "LogicalTableScanConverterRule" : null)
+                    .matches(joinType == CORRELATED ? QueryChecker.containsSubPlan("IgniteHashIndexSpool")
+                            : QueryChecker.matches("(?i).*IS NOT DISTINCT.*"))
+                    .matches(indexScan ? QueryChecker.containsIndexScan("PUBLIC", "T11") :
+                            QueryChecker.containsTableScan("PUBLIC", "T11"))
+                    .returns(2, 2)
+                    .returns(null, 3)
+                    .check();
+        } finally {
+            sql("DROP TABLE IF EXISTS t11");
+            sql("DROP TABLE IF EXISTS t22");
+        }
+    }
 
-        private final String[] disabledRules;
+    private static Stream<Arguments> joinTypes() {
+        List<Arguments> types = Arrays.stream(JoinType.values())
+                        .flatMap(v -> Stream.of(Arguments.of(v, false), Arguments.of(v, true))).collect(Collectors.toList());

Review Comment:
   you can just return stream here without collect result to list.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org