Class SqlBasicTypeNameSpec

java.lang.Object
org.apache.calcite.sql.SqlTypeNameSpec
org.apache.calcite.sql.SqlBasicTypeNameSpec
Direct Known Subclasses:
SqlAlienSystemTypeNameSpec

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
 
  • Constructor Details

    • SqlBasicTypeNameSpec

      public SqlBasicTypeNameSpec(SqlTypeName typeName, int precision, int scale, @Nullable 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, SqlParserPos pos)
    • SqlBasicTypeNameSpec

      public SqlBasicTypeNameSpec(SqlTypeName typeName, int precision, SqlParserPos pos)
    • SqlBasicTypeNameSpec

      public SqlBasicTypeNameSpec(SqlTypeName typeName, int precision, String charSetName, SqlParserPos pos)
    • SqlBasicTypeNameSpec

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

    • getScale

      public int getScale()
    • getPrecision

      public int getPrecision()
    • getCharSetName

      public @Nullable String getCharSetName()
    • equalsDeep

      public boolean equalsDeep(SqlTypeNameSpec node, Litmus litmus)
      Description copied from class: SqlTypeNameSpec
      Returns whether this spec is structurally equivalent to another spec.
      Specified by:
      equalsDeep in class SqlTypeNameSpec
    • 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