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


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/JoinColocationPlannerTest.java:
##########
@@ -70,10 +78,105 @@ public void joinSameTableSimpleAff() throws Exception {
     }
 
     /**
-     * Join of the same tables with a complex affinity is expected to be 
colocated.
+     * Join of the same tables with a simple affinity is expected to be 
colocated.
+     */
+    @Test
+    public void joinSameTableSimpleAffHashJoin() throws Exception {
+        IgniteTable tbl = simpleTable("TEST_TBL", DEFAULT_TBL_SIZE);
+
+        IgniteSchema schema = createSchema(tbl);
+
+        String sql = "select count(*) "
+                + "from TEST_TBL t1 "
+                + "join TEST_TBL t2 on t1.id = t2.id";
+
+        // Only hash join
+        RelNode phys = physicalPlan(sql, schema, "NestedLoopJoinConverter", 
"CorrelatedNestedLoopJoin", "MergeJoinConverter");
+
+        AbstractIgniteJoin join = findFirstNode(phys, 
byClass(AbstractIgniteJoin.class));
+        List<RelNode> joinNodes = findNodes(phys, 
byClass(AbstractIgniteJoin.class));
+
+        String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
+
+        assertThat(invalidPlanMsg, joinNodes.size(), equalTo(1));
+        assertThat(invalidPlanMsg, join, notNullValue());
+        assertThat(invalidPlanMsg, join.distribution().function().affinity(), 
is(true));
+    }
+
+    /**
+     * Hash join need to preserve left collation.
      */
     @Test
-    public void joinSameTableComplexAff() throws Exception {
+    public void hashJoinCheckLeftCollationsPropagation() throws Exception {
+        IgniteTable tbl1 = simpleTable("TEST_TBL", DEFAULT_TBL_SIZE);
+        IgniteTable tbl2 = complexTbl("TEST_TBL_CMPLX");
+
+        IgniteSchema schema = createSchema(tbl1, tbl2);
+
+        String sql = "select t1.ID, t2.ID1 "
+                + "from TEST_TBL_CMPLX t2 "
+                + "join TEST_TBL t1 on t1.id = t2.id1 "
+                + "order by t2.ID1 NULLS LAST, t2.ID2 NULLS LAST";
+
+        // Only hash join
+        RelNode phys = physicalPlan(sql, schema, "NestedLoopJoinConverter",
+                "CorrelatedNestedLoopJoin", "MergeJoinConverter", 
"JoinCommuteRule");
+
+        AbstractIgniteJoin join = findFirstNode(phys, 
byClass(AbstractIgniteJoin.class));
+        List<RelNode> joinNodes = findNodes(phys, 
byClass(AbstractIgniteJoin.class));
+        List<RelNode> sortNodes = findNodes(phys, byClass(IgniteSort.class));
+
+        String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
+
+        assertThat(invalidPlanMsg, sortNodes.size(), equalTo(0));
+        assertThat(invalidPlanMsg, joinNodes.size(), equalTo(1));
+        assertThat(invalidPlanMsg, join, notNullValue());
+    }
+
+    /**
+     * Hash join erase right collation.
+     */
+    @Test
+    public void hashJoinCheckRightCollations() throws Exception {

Review Comment:
   done



##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/JoinColocationPlannerTest.java:
##########
@@ -70,10 +78,105 @@ public void joinSameTableSimpleAff() throws Exception {
     }
 
     /**
-     * Join of the same tables with a complex affinity is expected to be 
colocated.
+     * Join of the same tables with a simple affinity is expected to be 
colocated.
+     */
+    @Test
+    public void joinSameTableSimpleAffHashJoin() throws Exception {
+        IgniteTable tbl = simpleTable("TEST_TBL", DEFAULT_TBL_SIZE);
+
+        IgniteSchema schema = createSchema(tbl);
+
+        String sql = "select count(*) "
+                + "from TEST_TBL t1 "
+                + "join TEST_TBL t2 on t1.id = t2.id";
+
+        // Only hash join
+        RelNode phys = physicalPlan(sql, schema, "NestedLoopJoinConverter", 
"CorrelatedNestedLoopJoin", "MergeJoinConverter");
+
+        AbstractIgniteJoin join = findFirstNode(phys, 
byClass(AbstractIgniteJoin.class));
+        List<RelNode> joinNodes = findNodes(phys, 
byClass(AbstractIgniteJoin.class));
+
+        String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
+
+        assertThat(invalidPlanMsg, joinNodes.size(), equalTo(1));
+        assertThat(invalidPlanMsg, join, notNullValue());
+        assertThat(invalidPlanMsg, join.distribution().function().affinity(), 
is(true));
+    }
+
+    /**
+     * Hash join need to preserve left collation.
      */
     @Test
-    public void joinSameTableComplexAff() throws Exception {
+    public void hashJoinCheckLeftCollationsPropagation() throws Exception {

Review Comment:
   done



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