This is an automated email from the ASF dual-hosted git repository.

mbudiu pushed a commit to branch issue7070
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 86bd30330f4be32495810c119ea3777e853b6b0f
Author: Mihai Budiu <[email protected]>
AuthorDate: Fri Oct 10 15:24:42 2025 -0700

    Unify static and non-static methods
    
    Signed-off-by: Mihai Budiu <[email protected]>
---
 .../java/org/apache/calcite/rex/RexSimplify.java   | 28 ++++++++--------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java 
b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
index 7d435108c3..1283a0f2e8 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
@@ -775,9 +775,9 @@ private <C extends Comparable<C>> RexNode 
simplifyComparison(RexCall e,
 
   /**
    * If this RexNode is a comparison against NULL, return FALSE, otherwise 
return it unchanged.
-   * This is a static simplified version of the function below.
    */
-  public static RexNode simplifyComparisonWithNull(RexNode e, RexBuilder 
rexBuilder) {
+  static RexNode simplifyComparisonWithNull(
+      RexNode e, RexBuilder rexBuilder, RexUnknownAs unknownAs) {
     final RexSimplify.Comparison comparison = RexSimplify.Comparison.of(e);
     if (comparison != null) {
       boolean againstNull = comparison.literal.isNull();
@@ -787,32 +787,24 @@ public static RexNode simplifyComparisonWithNull(RexNode 
e, RexBuilder rexBuilde
         againstNull = againstNull || ((RexLiteral) comparison.ref).isNull();
       }
       if (againstNull) {
-        return rexBuilder.makeLiteral(false);
+        return unknownAs == FALSE
+            ? rexBuilder.makeLiteral(false)
+            : rexBuilder.makeNullLiteral(e.getType());
       }
     }
     return e;
   }
 
+  public static RexNode simplifyComparisonWithNull(RexNode e, RexBuilder 
rexBuilder) {
+    return RexSimplify.simplifyComparisonWithNull(e, rexBuilder, FALSE);
+  }
+
   /**
    * If this RexNode is a comparison against NULL, return a simplified form,
    * otherwise return it unchanged.
    */
   public RexNode simplifyComparisonWithNull(RexNode e, RexUnknownAs unknownAs) 
{
-    final Comparison comparison = Comparison.of(e);
-    if (comparison != null) {
-      boolean againstNull = comparison.literal.isNull();
-      // There is another possibility to check: in a comparison like 1 = null,
-      // the "non-literal" side of the Comparison can be null
-      if (comparison.ref instanceof RexLiteral) {
-        againstNull = againstNull || ((RexLiteral) comparison.ref).isNull();
-      }
-      if (againstNull) {
-        return unknownAs == FALSE
-            ? rexBuilder.makeLiteral(false)
-            : rexBuilder.makeNullLiteral(e.getType());
-      }
-    }
-    return e;
+    return simplifyComparisonWithNull(e, this.rexBuilder, unknownAs);
   }
 
   /**

Reply via email to