Class SqlCollectionTypeNameSpec

  • public class SqlCollectionTypeNameSpec
    extends SqlTypeNameSpec
    A sql type name specification of collection type.

    The grammar definition in SQL-2011 IWD 9075-2:201?(E) 6.1 <collection type> is as following:

     <collection type> ::=
         <array type>
       | <multiset type>
     <array type> ::=
       <data type> ARRAY
       [ <left bracket or trigraph>
         <maximum cardinality>
         <right bracket or trigraph> ]
     <maximum cardinality> ::=
       <unsigned integer>
     <multiset type> ::=
       <data type> MULTISET

    This class is intended to be used in nested collection type, it can be used as the element type name of SqlDataTypeSpec. i.e. "int array array" or "int array multiset". For simple collection type like "int array", SqlBasicTypeNameSpec is descriptive enough.

    • Constructor Detail

      • SqlCollectionTypeNameSpec

        public SqlCollectionTypeNameSpec​(SqlTypeNameSpec elementTypeName,
                                         SqlTypeName collectionTypeName,
                                         SqlParserPos pos)
        Creates a SqlCollectionTypeNameSpec.
        elementTypeName - Type of the collection element.
        collectionTypeName - Collection type name.
        pos - Parser position, must not be null.
    • Method Detail

      • deriveType

        public RelDataType deriveType​(SqlValidator validator)
        Description copied from class: SqlTypeNameSpec
        Derive type from this SqlTypeNameSpec.
        Specified by:
        deriveType in class SqlTypeNameSpec
        validator - The sql validator.
        the RelDataType instance, throws exception if we could not deduce the type.
      • unparse

        public void unparse​(SqlWriter writer,
                            int leftPrec,
                            int rightPrec)
        Description copied from class: SqlTypeNameSpec
        Writes a SQL representation of this spec to a writer.
        Specified by:
        unparse in class SqlTypeNameSpec
      • createCollectionType

        private RelDataType createCollectionType​(RelDataType elementType,
                                                 RelDataTypeFactory typeFactory)
        Create collection data type.
        elementType - Type of the collection element.
        typeFactory - Type factory.
        The collection data type, or throw exception if the collection type name does not belong to SqlTypeName enumerations.