You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2025/04/10 09:14:58 UTC
(ignite) branch master updated: IGNITE-24756 SQL Calcite: Fix extraction of common part from disjunction in conditions - Fixes #11988.
This is an automated email from the ASF dual-hosted git repository.
alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 594ae77b0c8 IGNITE-24756 SQL Calcite: Fix extraction of common part from disjunction in conditions - Fixes #11988.
594ae77b0c8 is described below
commit 594ae77b0c87349a9a5607cc3cd874c6b08bb4a7
Author: Aleksey Plekhanov <pl...@gmail.com>
AuthorDate: Thu Apr 10 12:12:28 2025 +0300
IGNITE-24756 SQL Calcite: Fix extraction of common part from disjunction in conditions - Fixes #11988.
Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
.../query/calcite/prepare/IgnitePlanner.java | 5 +++++
.../planner/RexSimplificationPlannerTest.java | 20 ++++++++++----------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgnitePlanner.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgnitePlanner.java
index f7d8b584b81..4819eafed4c 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgnitePlanner.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgnitePlanner.java
@@ -681,6 +681,11 @@ public class IgnitePlanner implements Planner, RelOptTable.ViewExpander {
newOrOps.add(newAnd);
}
+ else {
+ newOrOps.clear();
+
+ break;
+ }
}
if (newOrOps.isEmpty())
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java
index db7ec8238c6..840e53ae862 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RexSimplificationPlannerTest.java
@@ -99,7 +99,7 @@ public class RexSimplificationPlannerTest extends AbstractPlannerTest {
"(c1 = 0 and c2 = 0) or " +
"(c1 = 0 and c2 = 1)", schema,
isIndexScan("T1", "IDX1")
- .and(s -> "AND(=($t0, 0), SEARCH($t1, Sarg[0, 1]))".equals(s.condition().toString())));
+ .and(s -> "=($t0, 0)".equals(s.condition().toString())));
// Disjunction equality last operand removal.
assertPlan("SELECT * FROM t1 WHERE " +
@@ -107,38 +107,38 @@ public class RexSimplificationPlannerTest extends AbstractPlannerTest {
"(c1 = 0 and c2 = 1) or " +
"(c1 = 0)", schema,
isIndexScan("T1", "IDX1")
- .and(s -> "AND(=($t0, 0), SEARCH($t1, Sarg[0, 1]))".equals(s.condition().toString())));
+ .and(s -> "=($t0, 0)".equals(s.condition().toString())));
- // Disjunction conjunction operand removal.
+ // Disjunction complex conjunction operand removal.
assertPlan("SELECT * FROM t1 WHERE " +
"(c1 = 0 and c2 = 0 and c3 = 0) or " +
"(c1 = 0 and c2 = 0 and c3 = 1) or " +
"(c1 = 0 and c2 = 0)", schema,
isIndexScan("T1", "IDX1")
- .and(s -> "AND(=($t0, 0), =($t1, 0), SEARCH($t2, Sarg[0, 1]))".equals(s.condition().toString())));
+ .and(s -> "AND(=($t0, 0), =($t1, 0))".equals(s.condition().toString())));
- // Disjunction removal.
+ // Disjunction all operands removal.
assertPlan("SELECT * FROM t1 WHERE " +
"(c1 = 0) or " +
"(c1 = 0)", schema,
isIndexScan("T1", "IDX1")
.and(s -> "=($t0, 0)".equals(s.condition().toString())));
- // Disjunction removal.
+ // Disjunction all except last operand removal.
assertPlan("SELECT * FROM t1 WHERE " +
"(c1 = 0) or " +
"(c1 = 0 and c2 = 0)", schema,
isIndexScan("T1", "IDX1")
- .and(s -> "AND(=($t0, 0), =($t1, 0))".equals(s.condition().toString())));
+ .and(s -> "=($t0, 0)".equals(s.condition().toString())));
- // Disjunction removal.
+ // Disjunction all except first operand removal.
assertPlan("SELECT * FROM t1 WHERE " +
"(c1 = 0 and c2 = 0) or " +
"(c1 = 0)", schema,
isIndexScan("T1", "IDX1")
- .and(s -> "AND(=($t0, 0), =($t1, 0))".equals(s.condition().toString())));
+ .and(s -> "=($t0, 0)".equals(s.condition().toString())));
- // Disjunction removal.
+ // Disjunction all complex operands removal.
assertPlan("SELECT * FROM t1 WHERE " +
"(c1 = 0 and c2 = 0) or " +
"(c2 = 0 and c1 = 0)", schema,