Class RexProgramBuilderBase

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<org.apache.calcite.rel.type.RelDataType,​org.apache.calcite.rex.RexDynamicParam> dynamicParams  
      protected org.apache.calcite.rex.RexExecutor executor  
      protected org.apache.calcite.rex.RexLiteral falseLiteral  
      protected static int MAX_FIELDS
      Input variables for tests should come from a struct type, so a struct is created where the first MAX_FIELDS are nullable, and the next MAX_FIELDS are not nullable.
      private org.apache.calcite.rel.type.RelDataType nonNullableBool  
      private org.apache.calcite.rel.type.RelDataType nonNullableInt  
      private org.apache.calcite.rel.type.RelDataType nonNullableVarchar  
      private org.apache.calcite.rel.type.RelDataType nullableBool  
      private org.apache.calcite.rel.type.RelDataType nullableInt  
      private org.apache.calcite.rel.type.RelDataType nullableVarchar  
      protected org.apache.calcite.rex.RexLiteral nullBool  
      protected org.apache.calcite.rex.RexLiteral nullInt  
      protected org.apache.calcite.rex.RexLiteral nullVarchar  
      protected org.apache.calcite.rex.RexBuilder rexBuilder  
      protected org.apache.calcite.rex.RexSimplify simplify  
      protected org.apache.calcite.rex.RexLiteral trueLiteral  
      protected org.apache.calcite.adapter.java.JavaTypeFactory typeFactory  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.apache.calcite.rex.RexNode abstractCast​(org.apache.calcite.rex.RexNode e, org.apache.calcite.rel.type.RelDataType type)
      Creates a call to the CAST operator.
      protected org.apache.calcite.rex.RexNode add​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode and​(java.lang.Iterable<? extends org.apache.calcite.rex.RexNode> nodes)  
      protected org.apache.calcite.rex.RexNode and​(org.apache.calcite.rex.RexNode... nodes)  
      private void assertArgValue​(int arg)  
      protected org.apache.calcite.rex.RexNode case_​(java.lang.Iterable<? extends org.apache.calcite.rex.RexNode> nodes)  
      protected org.apache.calcite.rex.RexNode case_​(org.apache.calcite.rex.RexNode... nodes)  
      protected org.apache.calcite.rex.RexNode cast​(org.apache.calcite.rex.RexNode e, org.apache.calcite.rel.type.RelDataType type)
      Creates a call to the CAST operator, expanding if possible, and not preserving nullability.
      protected org.apache.calcite.rex.RexNode coalesce​(org.apache.calcite.rex.RexNode... nodes)  
      protected org.apache.calcite.rex.RexNode div​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode divInt​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode eq​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode ge​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      private org.apache.calcite.rex.RexDynamicParam getDynamicParam​(org.apache.calcite.rel.type.RelDataType type, java.lang.String fieldNamePrefix)  
      protected org.apache.calcite.rex.RexNode gt​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode in​(org.apache.calcite.rex.RexNode node, org.apache.calcite.rex.RexNode... nodes)
      Generates x IN (y, z) expression when called as in(x, y, z).
      protected org.apache.calcite.rex.RexNode input​(org.apache.calcite.rel.type.RelDataType type, int arg)
      Generates input ref with given type and index.
      protected org.apache.calcite.rex.RexNode isDistinctFrom​(org.apache.calcite.rex.RexNode a, org.apache.calcite.rex.RexNode b)  
      protected org.apache.calcite.rex.RexNode isFalse​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode isNotDistinctFrom​(org.apache.calcite.rex.RexNode a, org.apache.calcite.rex.RexNode b)  
      protected org.apache.calcite.rex.RexNode isNotFalse​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode isNotNull​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode isNotTrue​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode isNull​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode isTrue​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode isUnknown​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode le​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode literal​(boolean value)  
      protected org.apache.calcite.rex.RexNode literal​(int value)  
      protected org.apache.calcite.rex.RexNode literal​(java.lang.Boolean value)  
      protected org.apache.calcite.rex.RexNode literal​(java.lang.Integer value)  
      protected org.apache.calcite.rex.RexNode literal​(java.lang.String value)  
      protected org.apache.calcite.rex.RexNode literal​(java.math.BigDecimal value)  
      protected org.apache.calcite.rex.RexNode literal​(java.math.BigDecimal value, org.apache.calcite.rel.type.RelDataType type)  
      protected org.apache.calcite.rex.RexNode lt​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode mul​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode ne​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rex.RexNode not​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexLiteral null_​(org.apache.calcite.rel.type.RelDataType type)
      Creates null literal with given type.
      protected org.apache.calcite.rel.type.RelDataType nullable​(org.apache.calcite.rel.type.RelDataType type)  
      protected org.apache.calcite.rex.RexNode nullIf​(org.apache.calcite.rex.RexNode node1, org.apache.calcite.rex.RexNode node2)  
      protected org.apache.calcite.rex.RexNode or​(java.lang.Iterable<? extends org.apache.calcite.rex.RexNode> nodes)  
      protected org.apache.calcite.rex.RexNode or​(org.apache.calcite.rex.RexNode... nodes)  
      protected org.apache.calcite.rex.RexNode plus​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      void setUp()  
      protected org.apache.calcite.rex.RexNode sub​(org.apache.calcite.rex.RexNode n1, org.apache.calcite.rex.RexNode n2)  
      protected org.apache.calcite.rel.type.RelDataType tBoolean()  
      protected org.apache.calcite.rel.type.RelDataType tBoolean​(boolean nullable)  
      protected org.apache.calcite.rel.type.RelDataType tInt()  
      protected org.apache.calcite.rel.type.RelDataType tInt​(boolean nullable)  
      protected org.apache.calcite.rel.type.RelDataType tVarchar()  
      protected org.apache.calcite.rel.type.RelDataType tVarchar​(boolean nullable)  
      protected org.apache.calcite.rex.RexNode unaryMinus​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode unaryPlus​(org.apache.calcite.rex.RexNode node)  
      protected org.apache.calcite.rex.RexNode vBool()
      Creates nullable boolean variable with index of 0.
      protected org.apache.calcite.rex.RexNode vBool​(int arg)
      Creates nullable boolean variable with index of arg (0-based).
      protected org.apache.calcite.rex.RexNode vBoolNotNull()
      Creates non-nullable boolean variable with index of 0.
      protected org.apache.calcite.rex.RexNode vBoolNotNull​(int arg)
      Creates non-nullable boolean variable with index of arg (0-based).
      protected org.apache.calcite.rex.RexNode vInt()
      Creates nullable int variable with index of 0.
      protected org.apache.calcite.rex.RexNode vInt​(int arg)
      Creates nullable int variable with index of arg (0-based).
      protected org.apache.calcite.rex.RexNode vIntNotNull()
      Creates non-nullable int variable with index of 0.
      protected org.apache.calcite.rex.RexNode vIntNotNull​(int arg)
      Creates non-nullable int variable with index of arg (0-based).
      protected org.apache.calcite.rex.RexNode vVarchar()
      Creates nullable varchar variable with index of 0.
      protected org.apache.calcite.rex.RexNode vVarchar​(int arg)
      Creates nullable varchar variable with index of arg (0-based).
      protected org.apache.calcite.rex.RexNode vVarcharNotNull()
      Creates non-nullable varchar variable with index of 0.
      protected org.apache.calcite.rex.RexNode vVarcharNotNull​(int arg)
      Creates non-nullable varchar variable with index of arg (0-based).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_FIELDS

        protected static final int MAX_FIELDS
        Input variables for tests should come from a struct type, so a struct is created where the first MAX_FIELDS are nullable, and the next MAX_FIELDS are not nullable.
        See Also:
        Constant Field Values
      • typeFactory

        protected org.apache.calcite.adapter.java.JavaTypeFactory typeFactory
      • rexBuilder

        protected org.apache.calcite.rex.RexBuilder rexBuilder
      • executor

        protected org.apache.calcite.rex.RexExecutor executor
      • simplify

        protected org.apache.calcite.rex.RexSimplify simplify
      • trueLiteral

        protected org.apache.calcite.rex.RexLiteral trueLiteral
      • falseLiteral

        protected org.apache.calcite.rex.RexLiteral falseLiteral
      • nullBool

        protected org.apache.calcite.rex.RexLiteral nullBool
      • nullInt

        protected org.apache.calcite.rex.RexLiteral nullInt
      • nullVarchar

        protected org.apache.calcite.rex.RexLiteral nullVarchar
      • nullableBool

        private org.apache.calcite.rel.type.RelDataType nullableBool
      • nonNullableBool

        private org.apache.calcite.rel.type.RelDataType nonNullableBool
      • nullableInt

        private org.apache.calcite.rel.type.RelDataType nullableInt
      • nonNullableInt

        private org.apache.calcite.rel.type.RelDataType nonNullableInt
      • nullableVarchar

        private org.apache.calcite.rel.type.RelDataType nullableVarchar
      • nonNullableVarchar

        private org.apache.calcite.rel.type.RelDataType nonNullableVarchar
      • dynamicParams

        private java.util.Map<org.apache.calcite.rel.type.RelDataType,​org.apache.calcite.rex.RexDynamicParam> dynamicParams
    • Constructor Detail

      • RexProgramBuilderBase

        public RexProgramBuilderBase()
    • Method Detail

      • setUp

        public void setUp()
      • getDynamicParam

        private org.apache.calcite.rex.RexDynamicParam getDynamicParam​(org.apache.calcite.rel.type.RelDataType type,
                                                                       java.lang.String fieldNamePrefix)
      • isNull

        protected org.apache.calcite.rex.RexNode isNull​(org.apache.calcite.rex.RexNode node)
      • isUnknown

        protected org.apache.calcite.rex.RexNode isUnknown​(org.apache.calcite.rex.RexNode node)
      • isNotNull

        protected org.apache.calcite.rex.RexNode isNotNull​(org.apache.calcite.rex.RexNode node)
      • isFalse

        protected org.apache.calcite.rex.RexNode isFalse​(org.apache.calcite.rex.RexNode node)
      • isNotFalse

        protected org.apache.calcite.rex.RexNode isNotFalse​(org.apache.calcite.rex.RexNode node)
      • isTrue

        protected org.apache.calcite.rex.RexNode isTrue​(org.apache.calcite.rex.RexNode node)
      • isNotTrue

        protected org.apache.calcite.rex.RexNode isNotTrue​(org.apache.calcite.rex.RexNode node)
      • isDistinctFrom

        protected org.apache.calcite.rex.RexNode isDistinctFrom​(org.apache.calcite.rex.RexNode a,
                                                                org.apache.calcite.rex.RexNode b)
      • isNotDistinctFrom

        protected org.apache.calcite.rex.RexNode isNotDistinctFrom​(org.apache.calcite.rex.RexNode a,
                                                                   org.apache.calcite.rex.RexNode b)
      • nullIf

        protected org.apache.calcite.rex.RexNode nullIf​(org.apache.calcite.rex.RexNode node1,
                                                        org.apache.calcite.rex.RexNode node2)
      • not

        protected org.apache.calcite.rex.RexNode not​(org.apache.calcite.rex.RexNode node)
      • unaryMinus

        protected org.apache.calcite.rex.RexNode unaryMinus​(org.apache.calcite.rex.RexNode node)
      • unaryPlus

        protected org.apache.calcite.rex.RexNode unaryPlus​(org.apache.calcite.rex.RexNode node)
      • and

        protected org.apache.calcite.rex.RexNode and​(org.apache.calcite.rex.RexNode... nodes)
      • and

        protected org.apache.calcite.rex.RexNode and​(java.lang.Iterable<? extends org.apache.calcite.rex.RexNode> nodes)
      • or

        protected org.apache.calcite.rex.RexNode or​(org.apache.calcite.rex.RexNode... nodes)
      • or

        protected org.apache.calcite.rex.RexNode or​(java.lang.Iterable<? extends org.apache.calcite.rex.RexNode> nodes)
      • case_

        protected org.apache.calcite.rex.RexNode case_​(org.apache.calcite.rex.RexNode... nodes)
      • case_

        protected org.apache.calcite.rex.RexNode case_​(java.lang.Iterable<? extends org.apache.calcite.rex.RexNode> nodes)
      • abstractCast

        protected org.apache.calcite.rex.RexNode abstractCast​(org.apache.calcite.rex.RexNode e,
                                                              org.apache.calcite.rel.type.RelDataType type)
        Creates a call to the CAST operator.

        This method enables to create CAST(42 nullable int) expressions.

        Parameters:
        e - input node
        type - type to cast to
        Returns:
        call to CAST operator
      • cast

        protected org.apache.calcite.rex.RexNode cast​(org.apache.calcite.rex.RexNode e,
                                                      org.apache.calcite.rel.type.RelDataType type)
        Creates a call to the CAST operator, expanding if possible, and not preserving nullability.

        Tries to expand the cast, and therefore the result may be something other than a RexCall to the CAST operator, such as a RexLiteral.

        Parameters:
        e - input node
        type - type to cast to
        Returns:
        input node converted to given type
      • eq

        protected org.apache.calcite.rex.RexNode eq​(org.apache.calcite.rex.RexNode n1,
                                                    org.apache.calcite.rex.RexNode n2)
      • ne

        protected org.apache.calcite.rex.RexNode ne​(org.apache.calcite.rex.RexNode n1,
                                                    org.apache.calcite.rex.RexNode n2)
      • le

        protected org.apache.calcite.rex.RexNode le​(org.apache.calcite.rex.RexNode n1,
                                                    org.apache.calcite.rex.RexNode n2)
      • lt

        protected org.apache.calcite.rex.RexNode lt​(org.apache.calcite.rex.RexNode n1,
                                                    org.apache.calcite.rex.RexNode n2)
      • ge

        protected org.apache.calcite.rex.RexNode ge​(org.apache.calcite.rex.RexNode n1,
                                                    org.apache.calcite.rex.RexNode n2)
      • gt

        protected org.apache.calcite.rex.RexNode gt​(org.apache.calcite.rex.RexNode n1,
                                                    org.apache.calcite.rex.RexNode n2)
      • plus

        protected org.apache.calcite.rex.RexNode plus​(org.apache.calcite.rex.RexNode n1,
                                                      org.apache.calcite.rex.RexNode n2)
      • mul

        protected org.apache.calcite.rex.RexNode mul​(org.apache.calcite.rex.RexNode n1,
                                                     org.apache.calcite.rex.RexNode n2)
      • coalesce

        protected org.apache.calcite.rex.RexNode coalesce​(org.apache.calcite.rex.RexNode... nodes)
      • divInt

        protected org.apache.calcite.rex.RexNode divInt​(org.apache.calcite.rex.RexNode n1,
                                                        org.apache.calcite.rex.RexNode n2)
      • div

        protected org.apache.calcite.rex.RexNode div​(org.apache.calcite.rex.RexNode n1,
                                                     org.apache.calcite.rex.RexNode n2)
      • sub

        protected org.apache.calcite.rex.RexNode sub​(org.apache.calcite.rex.RexNode n1,
                                                     org.apache.calcite.rex.RexNode n2)
      • add

        protected org.apache.calcite.rex.RexNode add​(org.apache.calcite.rex.RexNode n1,
                                                     org.apache.calcite.rex.RexNode n2)
      • in

        protected org.apache.calcite.rex.RexNode in​(org.apache.calcite.rex.RexNode node,
                                                    org.apache.calcite.rex.RexNode... nodes)
        Generates x IN (y, z) expression when called as in(x, y, z).
        Parameters:
        node - left side of the IN expression
        nodes - nodes in the right side of IN expression
        Returns:
        IN expression
      • nullable

        protected org.apache.calcite.rel.type.RelDataType nullable​(org.apache.calcite.rel.type.RelDataType type)
      • tVarchar

        protected org.apache.calcite.rel.type.RelDataType tVarchar()
      • tVarchar

        protected org.apache.calcite.rel.type.RelDataType tVarchar​(boolean nullable)
      • tBoolean

        protected org.apache.calcite.rel.type.RelDataType tBoolean()
      • tBoolean

        protected org.apache.calcite.rel.type.RelDataType tBoolean​(boolean nullable)
      • tInt

        protected org.apache.calcite.rel.type.RelDataType tInt()
      • tInt

        protected org.apache.calcite.rel.type.RelDataType tInt​(boolean nullable)
      • null_

        protected org.apache.calcite.rex.RexLiteral null_​(org.apache.calcite.rel.type.RelDataType type)
        Creates null literal with given type. For instance: null_(tInt())
        Parameters:
        type - type of required null
        Returns:
        null literal of a given type
      • literal

        protected org.apache.calcite.rex.RexNode literal​(boolean value)
      • literal

        protected org.apache.calcite.rex.RexNode literal​(java.lang.Boolean value)
      • literal

        protected org.apache.calcite.rex.RexNode literal​(int value)
      • literal

        protected org.apache.calcite.rex.RexNode literal​(java.math.BigDecimal value)
      • literal

        protected org.apache.calcite.rex.RexNode literal​(java.math.BigDecimal value,
                                                         org.apache.calcite.rel.type.RelDataType type)
      • literal

        protected org.apache.calcite.rex.RexNode literal​(java.lang.Integer value)
      • literal

        protected org.apache.calcite.rex.RexNode literal​(java.lang.String value)
      • input

        protected org.apache.calcite.rex.RexNode input​(org.apache.calcite.rel.type.RelDataType type,
                                                       int arg)
        Generates input ref with given type and index.

        Prefer vBool(), vInt() and so on.

        The problem with "input refs" is input(tInt(), 0).toString() yields $0, so the type of the expression is not printed, and it makes it hard to analyze the expressions.

        Parameters:
        type - desired type of the node
        arg - argument index (0-based)
        Returns:
        input ref with given type and index
      • assertArgValue

        private void assertArgValue​(int arg)
      • vBool

        protected org.apache.calcite.rex.RexNode vBool()
        Creates nullable boolean variable with index of 0. If you need several distinct variables, use vBool(int)
        Returns:
        nullable boolean variable with index of 0
      • vBool

        protected org.apache.calcite.rex.RexNode vBool​(int arg)
        Creates nullable boolean variable with index of arg (0-based). The resulting node would look like ?0.bool3 if arg is 3.
        Returns:
        nullable boolean variable with given index (0-based)
      • vBoolNotNull

        protected org.apache.calcite.rex.RexNode vBoolNotNull()
        Creates non-nullable boolean variable with index of 0. If you need several distinct variables, use vBoolNotNull(int). The resulting node would look like ?0.notNullBool0
        Returns:
        non-nullable boolean variable with index of 0
      • vBoolNotNull

        protected org.apache.calcite.rex.RexNode vBoolNotNull​(int arg)
        Creates non-nullable boolean variable with index of arg (0-based). The resulting node would look like ?0.notNullBool3 if arg is 3.
        Returns:
        non-nullable boolean variable with given index (0-based)
      • vInt

        protected org.apache.calcite.rex.RexNode vInt()
        Creates nullable int variable with index of 0. If you need several distinct variables, use vInt(int). The resulting node would look like ?0.notNullInt0
        Returns:
        nullable int variable with index of 0
      • vInt

        protected org.apache.calcite.rex.RexNode vInt​(int arg)
        Creates nullable int variable with index of arg (0-based). The resulting node would look like ?0.int3 if arg is 3.
        Returns:
        nullable int variable with given index (0-based)
      • vIntNotNull

        protected org.apache.calcite.rex.RexNode vIntNotNull()
        Creates non-nullable int variable with index of 0. If you need several distinct variables, use vIntNotNull(int). The resulting node would look like ?0.notNullInt0
        Returns:
        non-nullable int variable with index of 0
      • vIntNotNull

        protected org.apache.calcite.rex.RexNode vIntNotNull​(int arg)
        Creates non-nullable int variable with index of arg (0-based). The resulting node would look like ?0.notNullInt3 if arg is 3.
        Returns:
        non-nullable int variable with given index (0-based)
      • vVarchar

        protected org.apache.calcite.rex.RexNode vVarchar()
        Creates nullable varchar variable with index of 0. If you need several distinct variables, use vVarchar(int). The resulting node would look like ?0.notNullVarchar0
        Returns:
        nullable varchar variable with index of 0
      • vVarchar

        protected org.apache.calcite.rex.RexNode vVarchar​(int arg)
        Creates nullable varchar variable with index of arg (0-based). The resulting node would look like ?0.varchar3 if arg is 3.
        Returns:
        nullable varchar variable with given index (0-based)
      • vVarcharNotNull

        protected org.apache.calcite.rex.RexNode vVarcharNotNull()
        Creates non-nullable varchar variable with index of 0. If you need several distinct variables, use vVarcharNotNull(int). The resulting node would look like ?0.notNullVarchar0
        Returns:
        non-nullable varchar variable with index of 0
      • vVarcharNotNull

        protected org.apache.calcite.rex.RexNode vVarcharNotNull​(int arg)
        Creates non-nullable varchar variable with index of arg (0-based). The resulting node would look like ?0.notNullVarchar3 if arg is 3.
        Returns:
        non-nullable varchar variable with given index (0-based)