Class RexInterpreter

  • All Implemented Interfaces:
    RexVisitor<java.lang.Comparable>

    public class RexInterpreter
    extends java.lang.Object
    implements RexVisitor<java.lang.Comparable>
    Evaluates RexNode expressions.

    Caveats:

    • It uses interpretation, so it is not very efficient.
    • It is intended for testing, so does not cover very many functions and operators. (Feel free to contribute more!)
    • It is not well tested.
    • Field Detail

      • environment

        private final java.util.Map<RexNode,​java.lang.Comparable> environment
    • Constructor Detail

      • RexInterpreter

        private RexInterpreter​(java.util.Map<RexNode,​java.lang.Comparable> environment)
        Creates an interpreter.
        Parameters:
        environment - Values of certain expressions (usually RexInputRefs)
    • Method Detail

      • evaluate

        public static java.lang.Comparable evaluate​(RexNode e,
                                                    java.util.Map<RexNode,​java.lang.Comparable> map)
        Evaluates an expression in an environment.
      • unbound

        private java.lang.IllegalArgumentException unbound​(RexNode e)
      • getOrUnbound

        private java.lang.Comparable getOrUnbound​(RexNode e)
      • visitOver

        public java.lang.Comparable visitOver​(RexOver over)
        Specified by:
        visitOver in interface RexVisitor<java.lang.Comparable>
      • visitCall

        public java.lang.Comparable visitCall​(RexCall call)
        Specified by:
        visitCall in interface RexVisitor<java.lang.Comparable>
      • extract

        private java.lang.Comparable extract​(RexCall call,
                                             java.util.List<java.lang.Comparable> values)
      • coalesce

        private java.lang.Comparable coalesce​(RexCall call,
                                              java.util.List<java.lang.Comparable> values)
      • ceil

        private java.lang.Comparable ceil​(RexCall call,
                                          java.util.List<java.lang.Comparable> values)
      • subUnit

        private org.apache.calcite.avatica.util.TimeUnitRange subUnit​(org.apache.calcite.avatica.util.TimeUnitRange unit)
      • cast

        private java.lang.Comparable cast​(RexCall call,
                                          java.util.List<java.lang.Comparable> values)
      • not

        private java.lang.Comparable not​(java.lang.Comparable value)
      • case_

        private java.lang.Comparable case_​(java.util.List<java.lang.Comparable> values)
      • number

        private java.math.BigDecimal number​(java.lang.Comparable comparable)
      • compare

        private java.lang.Comparable compare​(java.util.List<java.lang.Comparable> values,
                                             java.util.function.IntPredicate p)
      • containsNull

        private boolean containsNull​(java.util.List<java.lang.Comparable> values)