Class RexNode

java.lang.Object
org.apache.calcite.rex.RexNode
Direct Known Subclasses:
RexCall, RexFieldAccess, RexLiteral, RexRangeRef, RexVariable

public abstract class RexNode
extends Object
Row expression.

Every row-expression has a type. (Compare with SqlNode, which is created before validation, and therefore types may not be available.)

Some common row-expressions are: RexLiteral (constant value), RexVariable (variable), RexCall (call to operator with operands). Expressions are generally created using a RexBuilder factory.

All sub-classes of RexNode are immutable.

  • Field Details

  • Constructor Details

  • Method Details

    • withNormalize

      @API(since="1.22", status=EXPERIMENTAL) public static RexNode.Closeable withNormalize​(boolean needNormalize)
      The digest of RexNode is normalized by default, however, sometimes a non-normalized representation is required. This API enables to skip normalization. Note: the returned value must be closed, and the API is designed to be used with a try-with-resources.
      Parameters:
      needNormalize - true if normalization should be enabled or false if it should be skipped
      Returns:
      a handle that should be closed to revert normalization state
    • skipNormalize

      @API(since="1.22", status=EXPERIMENTAL) public static RexNode.Closeable skipNormalize()
      The digest of RexNode is normalized by default, however, sometimes a non-normalized representation is required. This API enables to skip normalization. Note: the returned value must be closed, and the API is designed to be used with a try-with-resources.
      Returns:
      a handle that should be closed to revert normalization state
    • needNormalize

      @API(since="1.22", status=EXPERIMENTAL) protected static boolean needNormalize()
      The digest of RexNode is normalized by default, however, sometimes a non-normalized representation is required. This method enables subclasses to identify if normalization is required.
      Returns:
      true if the digest needs to be normalized
    • getType

      public abstract RelDataType getType()
    • isAlwaysTrue

      public boolean isAlwaysTrue()
      Returns whether this expression always returns true. (Such as if this expression is equal to the literal TRUE.)
    • isAlwaysFalse

      public boolean isAlwaysFalse()
      Returns whether this expression always returns false. (Such as if this expression is equal to the literal FALSE.)
    • isA

      public boolean isA​(SqlKind kind)
    • isA

      public boolean isA​(Collection<SqlKind> kinds)
    • getKind

      public SqlKind getKind()
      Returns the kind of node this is.
      Returns:
      Node kind, never null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringRaw

      @API(since="1.22", status=EXPERIMENTAL) public String toStringRaw()
      Returns string representation of this node.
      Returns:
      the same as toString(), but without normalizing the output
    • nodeCount

      public int nodeCount()
      Returns the number of nodes in this expression.

      Leaf nodes, such as RexInputRef or RexLiteral, have a count of 1. Calls have a count of 1 plus the sum of their operands.

      Node count is a measure of expression complexity that is used by some planner rules to prevent deeply nested expressions.

    • accept

      public abstract <R> R accept​(RexVisitor<R> visitor)
      Accepts a visitor, dispatching to the right overloaded visitXxx method.

      Also see RexUtil.apply(RexVisitor, java.util.List, RexNode), which applies a visitor to several expressions simultaneously.

    • accept

      public abstract <R,​ P> R accept​(RexBiVisitor<R,​P> visitor, P arg)
      Accepts a visitor with a payload, dispatching to the right overloaded RexBiVisitor.visitInputRef(RexInputRef, Object) visitXxx} method.
    • equals

      public abstract boolean equals​(Object obj)

      Every node must implement equals(java.lang.Object) based on its content

      Overrides:
      equals in class Object
    • hashCode

      public abstract int hashCode()

      Every node must implement hashCode() consistent with equals(java.lang.Object)

      Overrides:
      hashCode in class Object