Class 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 a RexNode expression.

    There are two modes of operation:

    • Usefail=true to throw an AssertionError as soon as an invalid node is detected:
      RexNode node;
      RelDataType rowType;
      assert new RexChecker(rowType, true).isValid(node);
      This mode requires that assertions are enabled.
    • 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 Detail

      • 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 an AssertionError 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 type
        context - Context of the enclosing RelNode, or null
        litmus - 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 an AssertionError 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 type
        context - Context of the enclosing RelNode, or null
        litmus - What to do if an error is detected