This is an automated email from the ASF dual-hosted git repository.
rubenada pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new afdea2ec79 [CALCITE-739] Extend RexUtil.pullFactors to recognize
additional common factors (follow-up)
afdea2ec79 is described below
commit afdea2ec790d507fb26c824ac2e3505dcae0ca80
Author: Ruben Quesada Lopez <[email protected]>
AuthorDate: Wed Sep 23 15:54:31 2026 +0100
[CALCITE-739] Extend RexUtil.pullFactors to recognize additional common
factors (follow-up)
---
core/src/main/java/org/apache/calcite/rex/RexUtil.java | 4 ++--
core/src/test/java/org/apache/calcite/rex/RexProgramTest.java | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
index 1c11b0e750..13f89bad92 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
@@ -2967,7 +2967,7 @@ private RexNode pull(RexNode rex) {
}
return and(Iterables.concat(factors.values(),
ImmutableList.of(or(list))));
default:
- return normalizeComparison(rex);
+ return rex;
}
}
@@ -2994,7 +2994,7 @@ private LinkedHashMap<RexNode, RexNode>
commonFactors(List<RexNode> nodes) {
if (i++ == 0) {
for (RexNode conjunction : RelOptUtil.conjunctions(node)) {
RexNode normalized = normalizeComparison(conjunction);
- map.put(normalized, normalized);
+ map.put(normalized, conjunction);
}
} else {
map.keySet().retainAll(
diff --git a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
index db66843473..dc3c5fb423 100644
--- a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
@@ -896,13 +896,13 @@ private void checkExponentialCnf(int n) {
final RexNode bool0 = rexBuilder.makeInputRef(booleanType, 0);
final RexNode bool1 = rexBuilder.makeInputRef(booleanType, 1);
final RexNode seven = literal(7);
- checkPullFactors(eq(ref6, ref3), "=($3, $6)");
- checkPullFactors(gt(ref6, ref3), "<($3, $6)");
- checkPullFactors(le(seven, ref3), ">=($3, 7)");
+ checkPullFactors(eq(ref6, ref3), "=($6, $3)");
+ checkPullFactors(gt(ref6, ref3), ">($6, $3)");
+ checkPullFactors(le(seven, ref3), "<=(7, $3)");
checkPullFactors(
or(and(eq(ref6, ref3), bool0),
and(eq(ref3, ref6), bool1)),
- "AND(=($3, $6), OR($0, $1))");
+ "AND(=($6, $3), OR($0, $1))");
}
@Test void testSimplify() {