Class RexLiteral

    • Constructor Detail

      • RexLiteral

        RexLiteral​(java.lang.Comparable value,
                   RelDataType type,
                   SqlTypeName typeName)
        Creates a RexLiteral.
    • Method Detail

      • valueMatchesType

        public static boolean valueMatchesType​(java.lang.Comparable value,
                                               SqlTypeName typeName,
                                               boolean strict)
        Returns:
        whether value is appropriate for its type (we have rules about these things)
      • toJavaString

        private static java.lang.String toJavaString​(java.lang.Comparable value,
                                                     SqlTypeName typeName)
      • getTimeUnits

        private static java.util.List<org.apache.calcite.avatica.util.TimeUnit> getTimeUnits​(SqlTypeName typeName)
        Returns a list of the time units covered by an interval type such as HOUR TO SECOND. Adds MILLISECOND if the end is SECOND, to deal with fractional seconds.
      • intervalString

        private java.lang.String intervalString​(java.math.BigDecimal v)
      • pad

        private static void pad​(java.lang.StringBuilder b,
                                java.lang.String s,
                                int width)
      • width

        private static int width​(org.apache.calcite.avatica.util.TimeUnit timeUnit)
      • printAsJava

        public void printAsJava​(java.io.PrintWriter pw)
        Prints the value this literal as a Java string constant.
      • fromJdbcString

        public static RexLiteral fromJdbcString​(RelDataType type,
                                                SqlTypeName typeName,
                                                java.lang.String literal)
        Converts a Jdbc string into a RexLiteral. This method accepts a string, as returned by the Jdbc method ResultSet.getString(), and restores the string into an equivalent RexLiteral. It allows one to use Jdbc strings as a common format for data.

        If a null literal is provided, then a null pointer will be returned.

        Parameters:
        type - data type of literal to be read
        typeName - type family of literal
        literal - the (non-SQL encoded) string representation, as returned by the Jdbc call to return a column as a string
        Returns:
        a typed RexLiteral, or null
      • getCalendarFormat

        private static java.lang.String getCalendarFormat​(SqlTypeName typeName)
      • getKind

        public SqlKind getKind()
        Description copied from class: RexNode
        Returns the kind of node this is.
        Overrides:
        getKind in class RexNode
        Returns:
        Node kind, never null
      • isNull

        public boolean isNull()
        Returns whether this literal's value is null.
      • getValue

        public java.lang.Comparable getValue()
        Returns the value of this literal.

        For backwards compatibility, returns DATE. TIME and TIMESTAMP as a Calendar value in UTC time zone.

      • getValue2

        public java.lang.Object getValue2()
        Returns the value of this literal, in the form that the calculator program builder wants it.
      • getValue3

        public java.lang.Object getValue3()
        Returns the value of this literal, in the form that the rex-to-lix translator wants it.
      • getValue4

        public java.lang.Comparable getValue4()
        Returns the value of this literal, in the form that RexInterpreter wants it.
      • getValueAs

        public <T> T getValueAs​(java.lang.Class<T> clazz)
        Returns the value of this literal as an instance of the specified class.

        The following SQL types allow more than one form:

        • CHAR as NlsString or String
        • TIME as TimeString, Integer (milliseconds since midnight), Calendar (in UTC)
        • DATE as DateString, Integer (days since 1970-01-01), Calendar
        • TIMESTAMP as TimestampString, Long (milliseconds since 1970-01-01 00:00:00), Calendar
        • DECIMAL as BigDecimal or Long

        Called with clazz = Comparable, returns the value in its native form.

        Type Parameters:
        T - Return type
        Parameters:
        clazz - Desired return type
        Returns:
        Value of this literal in the desired type
      • booleanValue

        public static boolean booleanValue​(RexNode node)
      • isAlwaysTrue

        public boolean isAlwaysTrue()
        Description copied from class: RexNode
        Returns whether this expression always returns true. (Such as if this expression is equal to the literal TRUE.)
        Overrides:
        isAlwaysTrue in class RexNode
      • isAlwaysFalse

        public boolean isAlwaysFalse()
        Description copied from class: RexNode
        Returns whether this expression always returns false. (Such as if this expression is equal to the literal FALSE.)
        Overrides:
        isAlwaysFalse in class RexNode
      • value

        public static java.lang.Comparable value​(RexNode node)
      • intValue

        public static int intValue​(RexNode node)
      • stringValue

        public static java.lang.String stringValue​(RexNode node)
      • findValue

        private static java.lang.Comparable findValue​(RexNode node)
      • isNullLiteral

        public static boolean isNullLiteral​(RexNode node)
      • equals

        private static boolean equals​(java.lang.Object o1,
                                      java.lang.Object o2)