Class Strong

java.lang.Object
org.apache.calcite.plan.Strong

public class Strong extends Object
Utilities for strong predicates.

A predicate is strong (or null-rejecting) with regard to selected subset of inputs if it is UNKNOWN if all inputs in selected subset are UNKNOWN.

By the way, UNKNOWN is just the boolean form of NULL.

Examples:

  • UNKNOWN is strong in [] (definitely null)
  • c = 1 is strong in [c] (definitely null if and only if c is null)
  • c IS NULL is not strong (always returns TRUE or FALSE, never null)
  • p1 AND p2 is strong in [p1, p2] (definitely null if either p1 is null or p2 is null)
  • p1 OR p2 is strong if p1 and p2 are strong
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    How whether an operator's operands are null affects whether a call to that operator evaluates to null.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    allStrong(List<RexNode> operands)
    Returns whether all expressions in a list are strong.
    boolean
    Returns whether the analyzed expression will definitely not return true (equivalently, will definitely return null or false).
    static boolean
    isNotTrue(RexNode node, ImmutableBitSet nullColumns)
    Returns whether the analyzed expression will definitely not return true (equivalently, will definitely return null or false) if all of a given set of input columns are null.
    boolean
    Returns whether a given field is definitely null.
    boolean
    Returns whether a given input is definitely null.
    boolean
    Returns whether an expression is definitely null.
    static boolean
    isNull(RexNode node, ImmutableBitSet nullColumns)
    Returns whether the analyzed expression will definitely return null if all of a given set of input columns are null.
    static boolean
    Returns whether a given expression is strong.
    static Strong
    of(com.google.common.collect.ImmutableSet<RexFieldAccess> nullFields)
    Returns a checker that consults a set to find out whether particular field may be null.
    static Strong
    of(ImmutableBitSet nullColumns)
    Returns a checker that consults a bit set to find out whether particular inputs may be null.
    policy(RexNode rexNode)
    Returns how to deduce whether a particular RexNode expression is null, given whether its arguments are null.
    policy(SqlOperator operator)
    Returns how to deduce whether a particular SqlOperator expression is null, given whether its arguments are null.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Strong

      public Strong()
  • Method Details

    • of

      public static Strong of(ImmutableBitSet nullColumns)
      Returns a checker that consults a bit set to find out whether particular inputs may be null.
    • of

      public static Strong of(com.google.common.collect.ImmutableSet<RexFieldAccess> nullFields)
      Returns a checker that consults a set to find out whether particular field may be null.
    • isNull

      public static boolean isNull(RexNode node, ImmutableBitSet nullColumns)
      Returns whether the analyzed expression will definitely return null if all of a given set of input columns are null.
    • isNotTrue

      public static boolean isNotTrue(RexNode node, ImmutableBitSet nullColumns)
      Returns whether the analyzed expression will definitely not return true (equivalently, will definitely return null or false) if all of a given set of input columns are null.
    • policy

      @Deprecated public static Strong.Policy policy(SqlKind kind)
      Returns how to deduce whether a particular kind of expression is null, given whether its arguments are null.
    • policy

      public static Strong.Policy policy(RexNode rexNode)
      Returns how to deduce whether a particular RexNode expression is null, given whether its arguments are null.
    • policy

      public static Strong.Policy policy(SqlOperator operator)
      Returns how to deduce whether a particular SqlOperator expression is null, given whether its arguments are null.
    • isStrong

      public static boolean isStrong(RexNode e)
      Returns whether a given expression is strong.

      Examples:

      • Returns true for c = 1 since it returns null if and only if c is null
      • Returns false for c IS NULL since it always returns TRUE or FALSE
      Parameters:
      e - Expression
      Returns:
      true if the expression is strong, false otherwise
    • allStrong

      public static boolean allStrong(List<RexNode> operands)
      Returns whether all expressions in a list are strong.
    • isNotTrue

      public boolean isNotTrue(RexNode node)
      Returns whether the analyzed expression will definitely not return true (equivalently, will definitely return null or false).
    • isNull

      public boolean isNull(RexNode node)
      Returns whether an expression is definitely null.

      The answer is based on calls to isNull(org.apache.calcite.rex.RexNode, org.apache.calcite.util.ImmutableBitSet) for its constituent expressions, and you may override methods to test hypotheses such as "if x is null, is x + y null?

    • isNull

      public boolean isNull(RexInputRef ref)
      Returns whether a given input is definitely null.
    • isNull

      public boolean isNull(RexFieldAccess ref)
      Returns whether a given field is definitely null.