Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-14 Thread via GitHub


asf-gitbox-commits closed pull request #12180: IGNITE-25875 SQL Calcite: 
Refactor PlannerTest
URL: https://github.com/apache/ignite/pull/12180


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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


sonarqubecloud[bot] commented on PR #12180:
URL: https://github.com/apache/ignite/pull/12180#issuecomment-3062439225

   ## [![Quality Gate 
Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png
 'Quality Gate 
Failed')](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180) 
**Quality Gate failed**  
   Failed conditions  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png
 '') [3 New Code 
Smells](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180) 
(required ≤ 1)  
 
   [See analysis details on SonarQube 
Cloud](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180)
   
   ##   
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png
 '') Catch issues before they fail your Quality Gate with our IDE extension 
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png
 '') [SonarQube for 
IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


Vladsz83 commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200772917


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;
+}
+
+/** */
+@Test
+public void testSplitterColocatedReplicatedReplicated() throws Exception {
+IgniteSchema schema = createSchema(
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3)),
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3))
+);
+
+String sql = "SELECT d.id, (d.id + 1) as i

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


sonarqubecloud[bot] commented on PR #12180:
URL: https://github.com/apache/ignite/pull/12180#issuecomment-3061996379

   ## [![Quality Gate 
Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png
 'Quality Gate 
Failed')](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180) 
**Quality Gate failed**  
   Failed conditions  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png
 '') [3 New Code 
Smells](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180) 
(required ≤ 1)  
 
   [See analysis details on SonarQube 
Cloud](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180)
   
   ##   
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png
 '') Catch issues before they fail your Quality Gate with our IDE extension 
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png
 '') [SonarQube for 
IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200511847


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java:
##
@@ -2794,6 +2797,26 @@ public void testInnerDeriveMixed2() throws Exception {
 assertNull(sortOnTopOfScan(rel, "RIGHT_T"));
 }
 
+/** */
+@Test
+public void testMergeJoinIsNotAppliedForNonEquiJoin() throws Exception {
+IgniteSchema schema = createSchema(
+createTable("EMP", 1000, IgniteDistributions.broadcast(),
+"ID", INTEGER, "NAME", VARCHAR, "DEPTNO", INTEGER)
+.addIndex("emp_idx", 1, 2),
+createTable("DEPT", 100, IgniteDistributions.broadcast(),
+"DEPTNO", INTEGER, "NAME", VARCHAR)
+.addIndex("dep_idx", 1, 0)
+);
+
+String sql = "select d.deptno, d.name, e.id, e.name from dept d join 
emp e " +
+"on d.deptno = e.deptno and e.name >= d.name order by e.name, 
d.deptno";
+
+assertPlan(sql, schema, nodeOrAnyChild(isInstanceOf(IgniteSort.class)
+.and(hasChildThat(isInstanceOf(IgniteNestedLoopJoin.class,

Review Comment:
   Ok, fixed



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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200509906


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),

Review Comment:
   Duplication is not an issue. It's just a distribution of partitions over 
nodes, no matter how they are distributed, but in this case distribution must 
be the same for both tables.



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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200505588


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java:
##
@@ -2794,6 +2797,26 @@ public void testInnerDeriveMixed2() throws Exception {
 assertNull(sortOnTopOfScan(rel, "RIGHT_T"));
 }
 
+/** */
+@Test
+public void testMergeJoinIsNotAppliedForNonEquiJoin() throws Exception {
+IgniteSchema schema = createSchema(
+createTable("EMP", 1000, IgniteDistributions.broadcast(),
+"ID", INTEGER, "NAME", VARCHAR, "DEPTNO", INTEGER)
+.addIndex("emp_idx", 1, 2),
+createTable("DEPT", 100, IgniteDistributions.broadcast(),
+"DEPTNO", INTEGER, "NAME", VARCHAR)
+.addIndex("dep_idx", 1, 0)

Review Comment:
   Here we check that condition `e.name >= d.name` is not applied for merge 
join even if we have a index on it. So 0, 1 will be incorrect test case ('name' 
should be first field in index)



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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200458250


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;
+}
+
+/** */
+@Test
+public void testSplitterColocatedReplicatedReplicated() throws Exception {
+IgniteSchema schema = createSchema(
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3)),
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3))
+);
+
+String sql = "SELECT d.id, (d.id + 1

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200453567


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;
+}
+
+/** */
+@Test
+public void testSplitterColocatedReplicatedReplicated() throws Exception {
+IgniteSchema schema = createSchema(
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3)),
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3))
+);
+
+String sql = "SELECT d.id, (d.id + 1

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200456309


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;
+}
+
+/** */
+@Test
+public void testSplitterColocatedReplicatedReplicated() throws Exception {
+IgniteSchema schema = createSchema(
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3)),
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3))
+);
+
+String sql = "SELECT d.id, (d.id + 1

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200451004


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;
+}
+
+/** */
+@Test
+public void testSplitterColocatedReplicatedReplicated() throws Exception {
+IgniteSchema schema = createSchema(
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3)),
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3))
+);
+
+String sql = "SELECT d.id, (d.id + 1

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200447804


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;

Review Comment:
   Here we check physical exchanges after splitting. Two fragments means one 
exchange.



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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


alex-plekhanov commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200444815


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;
+}
+
+/** */
+@Test
+public void testSplitterColocatedReplicatedReplicated() throws Exception {
+IgniteSchema schema = createSchema(
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3)),
+IgniteDistributions.broadcast(),
+ColocationGroup.forNodes(select(nodes, 0, 1, 2, 3))
+);
+
+String sql = "SELECT d.id, (d.id + 1

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-11 Thread via GitHub


Vladsz83 commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2200232276


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlanSplitterTest.java:
##
@@ -0,0 +1,280 @@
+/*
+ * 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.processors.query.calcite.planner;
+
+import java.util.Arrays;
+import java.util.function.Predicate;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.ExecutionPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepQueryPlan;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.QueryTemplate;
+import org.apache.ignite.internal.processors.query.calcite.prepare.Splitter;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static org.apache.calcite.sql.type.SqlTypeName.INTEGER;
+import static org.apache.calcite.sql.type.SqlTypeName.VARCHAR;
+
+/** */
+public class PlanSplitterTest extends AbstractPlannerTest {
+/** */
+private IgniteSchema createSchema(
+IgniteDistribution distribution1,
+ColocationGroup colocationGrp1,
+IgniteDistribution distribution2,
+ColocationGroup colocationGrp2
+) {
+return createSchema(
+createTable("DEVELOPER", distribution1, "ID", INTEGER, "NAME", 
VARCHAR, "PROJECTID", INTEGER)
+.setColocationGroup(colocationGrp1),
+createTable("PROJECT", distribution2, "ID", INTEGER, "NAME", 
VARCHAR, "VER", INTEGER)
+.setColocationGroup(colocationGrp2)
+);
+}
+
+/** */
+@Test
+public void testSplitterColocatedPartitionedPartitioned() throws Exception 
{
+IgniteSchema schema = createSchema(
+IgniteDistributions.affinity(0, "Developer", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+)),
+IgniteDistributions.affinity(0, "Project", "hash"),
+ColocationGroup.forAssignments(Arrays.asList(
+select(nodes, 0, 1),
+select(nodes, 1, 2),
+select(nodes, 2, 0),
+select(nodes, 0, 1),
+select(nodes, 1, 2)
+))
+);
+
+String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " +
+"FROM PUBLIC.Developer d JOIN (" +
+"SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" +
+") p " +
+"ON d.id = p.id0";
+
+// Data is partitioned and colocated, can be joined on remote nodes, 
one exchange is required to transfer to
+// initiator node.
+assertPlan(sql, schema, 
hasFragmentsCount(2).and(nodeOrAnyChild(isInstanceOf(Exchange.class;

Review Comment:
   With `nodeOrAnyChild(isInstanceOf(Exchange.class))` we can't be sure that 
there is exactly one exchange. 



##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java:
##
@@ -2794,6 +2797,26 @@ public void testInnerDeriveMixed2() throws Exception {
 assertNull(sortOnTopOfScan(rel, "RIGHT_T"));
 }
 
+/** */
+@Test
+public 

Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-10 Thread via GitHub


Vladsz83 commented on code in PR #12180:
URL: https://github.com/apache/ignite/pull/12180#discussion_r2198355561


##
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/MergeJoinPlannerTest.java:
##
@@ -2794,6 +2797,26 @@ public void testInnerDeriveMixed2() throws Exception {
 assertNull(sortOnTopOfScan(rel, "RIGHT_T"));
 }
 
+/** */
+@Test
+public void testMergeJoinIsNotAppliedForNonEquiJoin() throws Exception {
+IgniteSchema schema = createSchema(
+createTable("EMP", 1000, IgniteDistributions.broadcast(),
+"ID", INTEGER, "NAME", VARCHAR, "DEPTNO", INTEGER)
+.addIndex("emp_idx", 1, 2),
+createTable("DEPT", 100, IgniteDistributions.broadcast(),
+"DEPTNO", INTEGER, "NAME", VARCHAR)
+.addIndex("dep_idx", 1, 0)

Review Comment:
   Trivial, up to you. `0, 1` is is more convenient.



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



Re: [PR] IGNITE-25875 SQL Calcite: Refactor PlannerTest [ignite]

2025-07-10 Thread via GitHub


sonarqubecloud[bot] commented on PR #12180:
URL: https://github.com/apache/ignite/pull/12180#issuecomment-3056241676

   ## [![Quality Gate 
Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png
 'Quality Gate 
Failed')](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180) 
**Quality Gate failed**  
   Failed conditions  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png
 '') [3 New Code 
Smells](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180) 
(required ≤ 1)  
 
   [See analysis details on SonarQube 
Cloud](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=12180)
   
   ##   
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png
 '') Catch issues before they fail your Quality Gate with our IDE extension 
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png
 '') [SonarQube for 
IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


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