Class SqlBasicTypeNameSpec


  • public class SqlBasicTypeNameSpec
    extends SqlTypeNameSpec
    A sql type name specification of basic sql type.

    Supported basic sql types grammar:

       basicSqlType:
             GEOMETRY
         |   BOOLEAN
         |   [ INTEGER | INT ]
         |   TINYINT
         |   SMALLINT
         |   BIGINT
         |   REAL
         |   DOUBLE [ PRECISION ]
         |   FLOAT
         |   BINARY [ precision ]
         |   [ BINARY VARYING | VARBINARY ] [ precision ]
         |   [ DECIMAL | DEC | NUMERIC ] [ precision [, scale] ]
         |   ANY [ precision [, scale] ]
         |   charType [ precision ] [ charSet ]
         |   varcharType [ precision ] [ charSet ]
         |   DATE
         |   TIME [ precision ] [ timeZone ]
         |   TIMESTAMP [ precision ] [ timeZone ]
    
      charType:
             CHARACTER
         |   CHAR
    
      varcharType:
             charType VARYING
         |   VARCHAR
    
      charSet:
             CHARACTER SET charSetName
    
      timeZone:
             WITHOUT TIME ZONE
         |   WITH LOCAL TIME ZONE
     
    • Field Detail

      • precision

        private int precision
      • scale

        private int scale
      • charSetName

        private java.lang.String charSetName
    • Constructor Detail

      • SqlBasicTypeNameSpec

        public SqlBasicTypeNameSpec​(SqlTypeName typeName,
                                    int precision,
                                    int scale,
                                    @Nullable
                                    java.lang.String charSetName,
                                    SqlParserPos pos)
        Create a basic sql type name specification.
        Parameters:
        typeName - Type name.
        precision - Precision of the type name if it is allowed, default is -1.
        scale - Scale of the type name if it is allowed, default is -1.
        charSetName - Char set of the type, only works when the type belong to CHARACTER type family.
        pos - The parser position.
      • SqlBasicTypeNameSpec

        public SqlBasicTypeNameSpec​(SqlTypeName typeName,
                                    int precision,
                                    java.lang.String charSetName,
                                    SqlParserPos pos)
      • SqlBasicTypeNameSpec

        public SqlBasicTypeNameSpec​(SqlTypeName typeName,
                                    int precision,
                                    int scale,
                                    SqlParserPos pos)
    • Method Detail

      • getScale

        public int getScale()
      • getPrecision

        public int getPrecision()
      • getCharSetName

        public java.lang.String getCharSetName()
      • 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
      • deriveType

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

        private static boolean isWithLocalTimeZoneDef​(SqlTypeName typeName)
        Returns:
        true if this type name has "local time zone" definition.
      • stripLocalTimeZoneDef

        private SqlTypeName stripLocalTimeZoneDef​(SqlTypeName typeName)
        Remove the local time zone definition of the typeName.
        Parameters:
        typeName - Type name.
        Returns:
        new type name without local time zone definition.