Class RexCall
- Direct Known Subclasses:
Match.RexMRAggCall,RexOver,RexSubQuery,Window.RexWinAggCall
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 Summary
FieldsModifier and TypeFieldDescriptionprotected intCache of hash code.final intfinal SqlOperatorfinal com.google.common.collect.ImmutableList<RexNode>final SqlParserPosIn the calls which can produce runtime errors we carry the source position, so the backend can produce runtime error messages pointing to the original source position.final RelDataType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRexCall(RelDataType type, SqlOperator operator, List<? extends RexNode> operands) protectedRexCall(SqlParserPos pos, RelDataType type, SqlOperator operator, List<? extends RexNode> operands) -
Method Summary
Modifier and TypeMethodDescription<R,P> R accept(RexBiVisitor<R, P> visitor, P arg) Accepts a visitor with a payload, dispatching to the right overloadedRexBiVisitor.visitInputRef(RexInputRef, Object)visitXxx} method.<R> Raccept(RexVisitor<R> visitor) Accepts a visitor, dispatching to the right overloadedvisitXxxmethod.protected final voidAppends call operands without parenthesis.clone(RelDataType type, List<RexNode> operands) Creates a new call to the same operator with different operands.protected StringcomputeDigest(boolean withType) booleangetKind()Returns the kind of node this is.getType()inthashCode()booleanReturns whether this expression always returns false.booleanReturns whether this expression always returns true.intReturns the number of nodes in this expression.intfinal StringtoString()
-
Field Details
-
pos
In the calls which can produce runtime errors we carry the source position, so the backend can produce runtime error messages pointing to the original source position. For calls that are can never generate runtime failures, this field may be ZERO. Note that some optimizations may "lost" position information. -
op
-
operands
-
type
-
nodeCount
public final int nodeCount -
hash
protected int hashCache of hash code.
-
-
Constructor Details
-
RexCall
protected RexCall(SqlParserPos pos, RelDataType type, SqlOperator operator, List<? extends RexNode> operands) -
RexCall
-
-
Method Details
-
appendOperands
Appends call operands without parenthesis.RexLiteralmight omit data type depending on the context. For instance,null:BOOLEANvs=(true, null). The idea here is to omit "obvious" types for readability purposes while still maintainRelNode.getDigest()contract.- Parameters:
sb- destination- See Also:
-
computeDigest
-
getParserPosition
-
toString
-
accept
Description copied from class:RexNodeAccepts a visitor, dispatching to the right overloadedvisitXxxmethod.Also see
RexUtil.apply(RexVisitor, java.util.List, RexNode), which applies a visitor to several expressions simultaneously. -
accept
Description copied from class:RexNodeAccepts a visitor with a payload, dispatching to the right overloadedRexBiVisitor.visitInputRef(RexInputRef, Object)visitXxx} method. -
getType
-
isAlwaysTrue
public boolean isAlwaysTrue()Description copied from class:RexNodeReturns whether this expression always returns true. (Such as if this expression is equal to the literalTRUE.)- Overrides:
isAlwaysTruein classRexNode
-
isAlwaysFalse
public boolean isAlwaysFalse()Description copied from class:RexNodeReturns whether this expression always returns false. (Such as if this expression is equal to the literalFALSE.)- Overrides:
isAlwaysFalsein classRexNode
-
getKind
Description copied from class:RexNodeReturns the kind of node this is. -
getOperands
-
operandCount
public int operandCount() -
getOperator
-
nodeCount
public int nodeCount()Description copied from class:RexNodeReturns the number of nodes in this expression.Leaf nodes, such as
RexInputReforRexLiteral, 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.
-
clone
Creates a new call to the same operator with different operands.- Parameters:
type- Return typeoperands- Operands to call- Returns:
- New call
-
equals
Description copied from class:RexNodeEvery node must implement
RexNode.equals(java.lang.Object)based on its content -
hashCode
public int hashCode()Description copied from class:RexNodeEvery node must implement
RexNode.hashCode()consistent withRexNode.equals(java.lang.Object)
-