Package org.apache.calcite.rex
Class RexChecker
- All Implemented Interfaces:
RexVisitor<Boolean>
Visitor which checks the validity of a
RexNode
expression.
This visitor can operate in two modes, controlled by the Litmus
argument:
Litmus.THROW
causes the checker to throw anAssertionError
as soon as an invalid node is detected. Note: This mode requires that assertions are enabled.// Example usage of Litmus.THROW RexNode node; RelDataType rowType; RexChecker checker = new RexChecker(rowType, Litmus.THROW); node.accept(checker); // Will throw an AssertionError if node is invalid
Litmus.IGNORE
tests validity without throwing an error.// Example usage of Litmus.IGNORE RexNode node; RelDataType rowType; RexChecker checker = new RexChecker(rowType, Litmus.IGNORE); node.accept(checker); if (!checker.isValid()) { // Handle invalid node }
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final @Nullable RelNode.Context
protected int
protected final List<RelDataType>
protected final Litmus
Fields inherited from class org.apache.calcite.rex.RexVisitorImpl
deep
-
Constructor Summary
ConstructorDescriptionRexChecker
(List<RelDataType> inputTypeList, @Nullable RelNode.Context context, Litmus litmus) Creates a RexChecker with a given set of input fields.RexChecker
(RelDataType inputRowType, @Nullable RelNode.Context context, Litmus litmus) Creates a RexChecker with a given input row type. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of failures encountered.final boolean
Returns whether an expression is valid.visitFieldAccess
(RexFieldAccess fieldAccess) visitInputRef
(RexInputRef ref) visitLocalRef
(RexLocalRef ref) Methods inherited from class org.apache.calcite.rex.RexVisitorImpl
visitArrayAnd, visitArrayOr, visitDynamicParam, visitLambda, visitLambdaRef, visitLiteral, visitOver, visitPatternFieldRef, visitRangeRef, visitSubQuery, visitTableInputRef
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.rex.RexVisitor
visitEach, visitList, visitList
-
Field Details
-
context
-
litmus
-
inputTypeList
-
failCount
protected int failCount
-
-
Constructor Details
-
RexChecker
Creates a RexChecker with a given input row type.If
fail
is true, the checker will throw anAssertionError
if an invalid node is found and assertions are enabled.Otherwise, each method returns whether its part of the tree is valid.
- Parameters:
inputRowType
- Input row typecontext
- Context of the enclosingRelNode
, or nulllitmus
- What to do if an invalid node is detected
-
RexChecker
public RexChecker(List<RelDataType> inputTypeList, @Nullable RelNode.Context context, Litmus litmus) Creates a RexChecker with a given set of input fields.If
fail
is true, the checker will throw anAssertionError
if an invalid node is found and assertions are enabled.Otherwise, each method returns whether its part of the tree is valid.
- Parameters:
inputTypeList
- Input row typecontext
- Context of the enclosingRelNode
, or nulllitmus
- What to do if an error is detected
-
-
Method Details
-
getFailureCount
public int getFailureCount()Returns the number of failures encountered.- Returns:
- Number of failures
-
visitInputRef
- Specified by:
visitInputRef
in interfaceRexVisitor<Boolean>
- Overrides:
visitInputRef
in classRexVisitorImpl<@Nullable Boolean>
-
visitLocalRef
- Specified by:
visitLocalRef
in interfaceRexVisitor<Boolean>
- Overrides:
visitLocalRef
in classRexVisitorImpl<@Nullable Boolean>
-
visitCall
- Specified by:
visitCall
in interfaceRexVisitor<Boolean>
- Overrides:
visitCall
in classRexVisitorImpl<@Nullable Boolean>
-
visitFieldAccess
- Specified by:
visitFieldAccess
in interfaceRexVisitor<Boolean>
- Overrides:
visitFieldAccess
in classRexVisitorImpl<@Nullable Boolean>
-
visitCorrelVariable
- Specified by:
visitCorrelVariable
in interfaceRexVisitor<Boolean>
- Overrides:
visitCorrelVariable
in classRexVisitorImpl<@Nullable Boolean>
-
isValid
Returns whether an expression is valid.
-