Class RelDataTypeImpl

    • Field Detail

      • digest

        protected java.lang.String digest
    • Constructor Detail

      • RelDataTypeImpl

        protected RelDataTypeImpl​(java.util.List<? extends RelDataTypeField> fieldList)
        Creates a RelDataTypeImpl.
        Parameters:
        fieldList - List of fields
      • RelDataTypeImpl

        protected RelDataTypeImpl()
        Default constructor, to allow derived classes such as BasicSqlType to be Serializable.

        (The serialization specification says that a class can be serializable even if its base class is not serializable, provided that the base class has a public or protected zero-args constructor.)

    • Method Detail

      • getField

        public RelDataTypeField getField​(java.lang.String fieldName,
                                         boolean caseSensitive,
                                         boolean elideRecord)
        Description copied from interface: RelDataType
        Looks up a field by name.

        NOTE: Be careful choosing the value of caseSensitive:

        • If the field name was supplied by an end-user (e.g. as a column alias in SQL), use your session's case-sensitivity setting.
        • Only hard-code true if you are sure that the field name is internally generated.
        • Hard-coding false is almost certainly wrong.
        Specified by:
        getField in interface RelDataType
        Parameters:
        fieldName - Name of field to find
        caseSensitive - Whether match is case-sensitive
        elideRecord - Whether to find fields nested within records
        Returns:
        named field, or null if not found
      • getFieldRecurse

        private static void getFieldRecurse​(java.util.List<RelDataTypeImpl.Slot> slots,
                                            RelDataType type,
                                            int depth,
                                            java.lang.String fieldName,
                                            boolean caseSensitive)
      • getFieldList

        public java.util.List<RelDataTypeField> getFieldList()
        Description copied from interface: RelDataType
        Gets the fields in a struct type. The field count is equal to the size of the returned list.
        Specified by:
        getFieldList in interface RelDataType
        Returns:
        read-only list of fields
      • getFieldNames

        public java.util.List<java.lang.String> getFieldNames()
        Description copied from interface: RelDataType
        Returns the names of the fields in a struct type. The field count is equal to the size of the returned list.
        Specified by:
        getFieldNames in interface RelDataType
        Returns:
        read-only list of field names
      • getStructKind

        public StructKind getStructKind()
        Description copied from interface: RelDataType
        Returns the rule for resolving the fields of a structured type, or StructKind.NONE if this is not a structured type.
        Specified by:
        getStructKind in interface RelDataType
        Returns:
        the StructKind that determines how this type's fields are resolved
      • getComponentType

        public RelDataType getComponentType()
        Description copied from interface: RelDataType
        Gets the component type if this type is a collection, otherwise null.
        Specified by:
        getComponentType in interface RelDataType
        Returns:
        canonical type descriptor for components
      • getKeyType

        public RelDataType getKeyType()
        Description copied from interface: RelDataType
        Gets the key type if this type is a map, otherwise null.
        Specified by:
        getKeyType in interface RelDataType
        Returns:
        canonical type descriptor for key
      • getValueType

        public RelDataType getValueType()
        Description copied from interface: RelDataType
        Gets the value type if this type is a map, otherwise null.
        Specified by:
        getValueType in interface RelDataType
        Returns:
        canonical type descriptor for value
      • isStruct

        public boolean isStruct()
        Description copied from interface: RelDataType
        Queries whether this is a structured type.
        Specified by:
        isStruct in interface RelDataType
        Returns:
        whether this type has fields; examples include rows and user-defined structured types in SQL, and classes in Java
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getFullTypeString

        public java.lang.String getFullTypeString()
        Description copied from interface: RelDataType
        Gets a string representation of this type with full detail such as character set and nullability. The string must serve as a "digest" for this type, meaning two types can be considered identical iff their digests are equal.
        Specified by:
        getFullTypeString in interface RelDataType
        Returns:
        full type string
      • isNullable

        public boolean isNullable()
        Description copied from interface: RelDataType
        Queries whether this type allows null values.
        Specified by:
        isNullable in interface RelDataType
        Returns:
        whether type allows null values
      • getCharset

        public java.nio.charset.Charset getCharset()
        Description copied from interface: RelDataType
        Gets this type's character set, or null if this type cannot carry a character set or has no character set defined.
        Specified by:
        getCharset in interface RelDataType
        Returns:
        charset of type
      • getCollation

        public SqlCollation getCollation()
        Description copied from interface: RelDataType
        Gets this type's collation, or null if this type cannot carry a collation or has no collation defined.
        Specified by:
        getCollation in interface RelDataType
        Returns:
        collation of type
      • getPrecision

        public int getPrecision()
        Description copied from interface: RelDataType
        Gets the JDBC-defined precision for values of this type. Note that this is not always the same as the user-specified precision. For example, the type INTEGER has no user-specified precision, but this method returns 10 for an INTEGER type.

        Returns RelDataType.PRECISION_NOT_SPECIFIED (-1) if precision is not applicable for this type.

        Specified by:
        getPrecision in interface RelDataType
        Returns:
        number of decimal digits for exact numeric types; number of decimal digits in mantissa for approximate numeric types; number of decimal digits for fractional seconds of datetime types; length in characters for character types; length in bytes for binary types; length in bits for bit types; 1 for BOOLEAN; -1 if precision is not valid for this type
      • getFamily

        public RelDataTypeFamily getFamily()
        Description copied from interface: RelDataType
        Gets a canonical object representing the family of this type. Two values can be compared if and only if their types are in the same family.
        Specified by:
        getFamily in interface RelDataType
        Returns:
        canonical object representing type family
      • generateTypeString

        protected abstract void generateTypeString​(java.lang.StringBuilder sb,
                                                   boolean withDetail)
        Generates a string representation of this type.
        Parameters:
        sb - StringBuilder into which to generate the string
        withDetail - when true, all detail information needed to compute a unique digest (and return from getFullTypeString) should be included;
      • computeDigest

        protected void computeDigest()
        Computes the digest field. This should be called in every non-abstract subclass constructor once the type is fully defined.
      • toString

        public java.lang.String toString()
        Description copied from interface: RelDataType
        Gets a string representation of this type without detail such as character set and nullability.
        Specified by:
        toString in interface RelDataType
        Overrides:
        toString in class java.lang.Object
        Returns:
        abbreviated type string
      • proto

        public static RelProtoDataType proto​(SqlTypeName typeName,
                                             boolean nullable)
        Returns a RelProtoDataType that will create a type typeName.

        For example, proto(SqlTypeName.DATE), false will create DATE NOT NULL.

        Parameters:
        typeName - Type name
        nullable - Whether nullable
        Returns:
        Proto data type
      • proto

        public static RelProtoDataType proto​(SqlTypeName typeName,
                                             int precision,
                                             boolean nullable)
        Returns a RelProtoDataType that will create a type typeName(precision).

        For example, proto(SqlTypeName.VARCHAR, 100, false) will create VARCHAR(100) NOT NULL.

        Parameters:
        typeName - Type name
        precision - Precision
        nullable - Whether nullable
        Returns:
        Proto data type
      • proto

        public static RelProtoDataType proto​(SqlTypeName typeName,
                                             int precision,
                                             int scale,
                                             boolean nullable)
        Returns a RelProtoDataType that will create a type typeName(precision, scale).

        For example, proto(SqlTypeName.DECIMAL, 7, 2, false) will create DECIMAL(7, 2) NOT NULL.

        Parameters:
        typeName - Type name
        precision - Precision
        scale - Scale
        nullable - Whether nullable
        Returns:
        Proto data type
      • extra

        public static RelDataTypeField extra​(RelDataType rowType)
        Returns the "extra" field in a row type whose presence signals that fields will come into existence just by asking for them.
        Parameters:
        rowType - Row type
        Returns:
        The "extra" field, or null
      • isDynamicStruct

        public boolean isDynamicStruct()
        Specified by:
        isDynamicStruct in interface RelDataType
        Returns:
        whether it has dynamic structure (for "schema-on-read" table)