Package org.apache.calcite.rex
Class RexChecker
- java.lang.Object
-
- org.apache.calcite.rex.RexVisitorImpl<java.lang.Boolean>
-
- org.apache.calcite.rex.RexChecker
-
- All Implemented Interfaces:
RexVisitor<java.lang.Boolean>
- Direct Known Subclasses:
RexProgram.Checker
public class RexChecker extends RexVisitorImpl<java.lang.Boolean>
Visitor which checks the validity of aRexNode
expression.There are two modes of operation:
- Use
fail=true
to throw anAssertionError
as soon as an invalid node is detected:
This mode requires that assertions are enabled.RexNode node;
RelDataType rowType;
assert new RexChecker(rowType, true).isValid(node); - Use
fail=false
to test for validity without throwing an error.RexNode node;
RelDataType rowType;
RexChecker checker = new RexChecker(rowType, false);
node.accept(checker);
if (!checker.valid) {
...
}
- See Also:
RexNode
-
-
Field Summary
Fields Modifier and Type Field Description protected RelNode.Context
context
protected int
failCount
protected java.util.List<RelDataType>
inputTypeList
protected Litmus
litmus
-
Fields inherited from class org.apache.calcite.rex.RexVisitorImpl
deep
-
-
Constructor Summary
Constructors Constructor Description RexChecker(java.util.List<RelDataType> inputTypeList, RelNode.Context context, Litmus litmus)
Creates a RexChecker with a given set of input fields.RexChecker(RelDataType inputRowType, RelNode.Context context, Litmus litmus)
Creates a RexChecker with a given input row type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getFailureCount()
Returns the number of failures encountered.boolean
isValid(RexNode expr)
Returns whether an expression is valid.java.lang.Boolean
visitCall(RexCall call)
java.lang.Boolean
visitCorrelVariable(RexCorrelVariable v)
java.lang.Boolean
visitFieldAccess(RexFieldAccess fieldAccess)
java.lang.Boolean
visitInputRef(RexInputRef ref)
java.lang.Boolean
visitLocalRef(RexLocalRef ref)
-
Methods inherited from class org.apache.calcite.rex.RexVisitorImpl
visitArrayAnd, visitArrayOr, visitDynamicParam, visitLiteral, visitOver, visitPatternFieldRef, visitRangeRef, visitSubQuery, visitTableInputRef
-
-
-
-
Field Detail
-
context
protected final RelNode.Context context
-
litmus
protected final Litmus litmus
-
inputTypeList
protected final java.util.List<RelDataType> inputTypeList
-
failCount
protected int failCount
-
-
Constructor Detail
-
RexChecker
public RexChecker(RelDataType inputRowType, RelNode.Context context, Litmus litmus)
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(java.util.List<RelDataType> inputTypeList, 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 Detail
-
getFailureCount
public int getFailureCount()
Returns the number of failures encountered.- Returns:
- Number of failures
-
visitInputRef
public java.lang.Boolean visitInputRef(RexInputRef ref)
- Specified by:
visitInputRef
in interfaceRexVisitor<java.lang.Boolean>
- Overrides:
visitInputRef
in classRexVisitorImpl<java.lang.Boolean>
-
visitLocalRef
public java.lang.Boolean visitLocalRef(RexLocalRef ref)
- Specified by:
visitLocalRef
in interfaceRexVisitor<java.lang.Boolean>
- Overrides:
visitLocalRef
in classRexVisitorImpl<java.lang.Boolean>
-
visitCall
public java.lang.Boolean visitCall(RexCall call)
- Specified by:
visitCall
in interfaceRexVisitor<java.lang.Boolean>
- Overrides:
visitCall
in classRexVisitorImpl<java.lang.Boolean>
-
visitFieldAccess
public java.lang.Boolean visitFieldAccess(RexFieldAccess fieldAccess)
- Specified by:
visitFieldAccess
in interfaceRexVisitor<java.lang.Boolean>
- Overrides:
visitFieldAccess
in classRexVisitorImpl<java.lang.Boolean>
-
visitCorrelVariable
public java.lang.Boolean visitCorrelVariable(RexCorrelVariable v)
- Specified by:
visitCorrelVariable
in interfaceRexVisitor<java.lang.Boolean>
- Overrides:
visitCorrelVariable
in classRexVisitorImpl<java.lang.Boolean>
-
isValid
public final boolean isValid(RexNode expr)
Returns whether an expression is valid.
-
-