Class RexCall

java.lang.Object
org.apache.calcite.rex.RexNode
org.apache.calcite.rex.RexCall
Direct Known Subclasses:
Match.RexMRAggCall, RexOver, RexSubQuery, Window.RexWinAggCall

public class RexCall extends RexNode
An expression formed by a call to an operator with zero or more expressions as operands.

Operators may be binary, unary, functions, special syntactic constructs like CASE ... WHEN ... END, or even internally generated constructs like implicit type conversions. The syntax of the operator is really irrelevant, because row-expressions (unlike SQL expressions) do not directly represent a piece of source code.

It's not often necessary to sub-class this class. The smarts should be in the operator, rather than the call. Any extra information about the call can often be encoded as extra arguments. (These don't need to be hidden, because no one is going to be generating source code from this tree.)

  • Field Details

    • op

      public final SqlOperator op
    • operands

      public final com.google.common.collect.ImmutableList<RexNode> operands
    • type

      public final RelDataType type
    • nodeCount

      public final int nodeCount
    • hash

      protected int hash
      Cache of hash code.
  • Constructor Details

  • Method Details

    • appendOperands

      protected final void appendOperands(StringBuilder sb)
      Appends call operands without parenthesis. RexLiteral might omit data type depending on the context. For instance, null:BOOLEAN vs =(true, null). The idea here is to omit "obvious" types for readability purposes while still maintain RelNode.getDigest() contract.
      Parameters:
      sb - destination
      See Also:
    • computeDigest

      protected String computeDigest(boolean withType)
    • toString

      public final String toString()
      Overrides:
      toString in class RexNode
    • accept

      public <R> R accept(RexVisitor<R> visitor)
      Description copied from class: RexNode
      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.

      Specified by:
      accept in class RexNode
    • accept

      public <R, P> R accept(RexBiVisitor<R,P> visitor, P arg)
      Description copied from class: RexNode
      Accepts a visitor with a payload, dispatching to the right overloaded RexBiVisitor.visitInputRef(RexInputRef, Object) visitXxx} method.
      Specified by:
      accept in class RexNode
    • getType

      public RelDataType getType()
      Specified by:
      getType in class RexNode
    • isAlwaysTrue

      public boolean isAlwaysTrue()
      Description copied from class: RexNode
      Returns whether this expression always returns true. (Such as if this expression is equal to the literal TRUE.)
      Overrides:
      isAlwaysTrue in class RexNode
    • isAlwaysFalse

      public boolean isAlwaysFalse()
      Description copied from class: RexNode
      Returns whether this expression always returns false. (Such as if this expression is equal to the literal FALSE.)
      Overrides:
      isAlwaysFalse in class RexNode
    • getKind

      public SqlKind getKind()
      Description copied from class: RexNode
      Returns the kind of node this is.
      Overrides:
      getKind in class RexNode
      Returns:
      Node kind, never null
    • getOperands

      public List<RexNode> getOperands()
    • operandCount

      public int operandCount()
    • getOperator

      public SqlOperator getOperator()
    • nodeCount

      public int nodeCount()
      Description copied from class: RexNode
      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.

      Overrides:
      nodeCount in class RexNode
    • clone

      public RexCall clone(RelDataType type, List<RexNode> operands)
      Creates a new call to the same operator with different operands.
      Parameters:
      type - Return type
      operands - Operands to call
      Returns:
      New call
    • equals

      public boolean equals(@Nullable Object o)
      Description copied from class: RexNode

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

      Specified by:
      equals in class RexNode
    • hashCode

      public int hashCode()
      Description copied from class: RexNode

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

      Specified by:
      hashCode in class RexNode