jacques-n commented on a change in pull request #973: [CALCITE-2742] Update 
USER and SYSTEM_USER to use DataContext for value
URL: https://github.com/apache/calcite/pull/973#discussion_r287147282
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java
 ##########
 @@ -1069,6 +1139,117 @@ private void reduceCasts(RexCall outerCast) {
       }
     }
   }
+
+  /**
+   * An immutable object capturing the set of options to be used for reducing
+   * expressions.
+   */
+  public static final class ReductionOptions {
+    private final boolean matchNullability;
+    private final boolean unknownAsFalse;
+    private final boolean treatDynamicCallsAsNonConstant;
+
+    private ReductionOptions(
+        boolean matchNullability,
+        boolean unknownAsFalse,
+        boolean treatDynamicCallsAsNonConstant) {
+      this.matchNullability = matchNullability;
+      this.unknownAsFalse = unknownAsFalse;
+      this.treatDynamicCallsAsNonConstant = treatDynamicCallsAsNonConstant;
+    }
+
+    /**
+     * Update the options to control dynamic treatment.
+     *
+     * @param treatDynamicCallsAsNonConstant Whether to treat dynamic 
functions as
+     *                                       non-constants (defaults to true)
+     * @return A new set of ReductionOptions
+     */
+    public ReductionOptions treatDynamicCallsAsNonConstant(
+        boolean treatDynamicCallsAsNonConstant) {
+      return new ReductionOptions(
+          this.matchNullability,
+          this.unknownAsFalse,
+          treatDynamicCallsAsNonConstant);
+    }
+
+    /**
+     * <p> Update the options to control nullability matching.
+     *
+     * <p>The {@code matchNullability} flag comes into play when reducing a
+     * expression whose type is nullable. Suppose we are reducing an expression
+     * {@code CASE WHEN 'a' = 'a' THEN 1 ELSE NULL END}. Before reduction the
+     * type is {@code INTEGER} (nullable), but after reduction the literal 1 
has
+     * type {@code INTEGER NOT NULL}.
+     *
+     * <p>In some situations it is more important to preserve types; in this
 
 Review comment:
   This functionality and comment already existed. This patch simply moved the 
comment. If you think this should be improved I suggest that you open a ticket 
to address separately.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to