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.THROWcauses the checker to throw anAssertionErroras 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.IGNOREtests 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
FieldsModifier and TypeFieldDescriptionprotected final @Nullable RelNode.Contextprotected intprotected final List<RelDataType>protected final LitmusFields inherited from class org.apache.calcite.rex.RexVisitorImpl
deep -
Constructor Summary
ConstructorsConstructorDescriptionRexChecker(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 TypeMethodDescriptionintReturns the number of failures encountered.final booleanReturns 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, visitTableInputRefMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
failis true, the checker will throw anAssertionErrorif 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
failis true, the checker will throw anAssertionErrorif 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:
visitInputRefin interfaceRexVisitor<Boolean>- Overrides:
visitInputRefin classRexVisitorImpl<@Nullable Boolean>
-
visitLocalRef
- Specified by:
visitLocalRefin interfaceRexVisitor<Boolean>- Overrides:
visitLocalRefin classRexVisitorImpl<@Nullable Boolean>
-
visitCall
- Specified by:
visitCallin interfaceRexVisitor<Boolean>- Overrides:
visitCallin classRexVisitorImpl<@Nullable Boolean>
-
visitFieldAccess
- Specified by:
visitFieldAccessin interfaceRexVisitor<Boolean>- Overrides:
visitFieldAccessin classRexVisitorImpl<@Nullable Boolean>
-
visitCorrelVariable
- Specified by:
visitCorrelVariablein interfaceRexVisitor<Boolean>- Overrides:
visitCorrelVariablein classRexVisitorImpl<@Nullable Boolean>
-
isValid
Returns whether an expression is valid.
-