Package org.apache.calcite.sql.type
Enum SqlTypeName
- All Implemented Interfaces:
Serializable
,Comparable<SqlTypeName>
,Constable
Enumeration of the type names which can be used to construct a SQL type.
Rationale for this class's existence (instead of just using the standard
java.sql.Type ordinals):
Types
does not include all SQL2003 data-types;- SqlTypeName provides a type-safe enumeration;
- SqlTypeName provides a place to hang extra information such as whether the type carries precision and scale.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionSpatial type. -
Field Summary
Modifier and TypeFieldDescriptionstatic final List<SqlTypeName>
static final List<SqlTypeName>
static final List<SqlTypeName>
static final List<SqlTypeName>
static final List<SqlTypeName>
static final List<SqlTypeName>
static final Set<SqlTypeName>
static final int
static final int
static final List<SqlTypeName>
static final List<SqlTypeName>
static final List<SqlTypeName>
static final List<SqlTypeName>
static final Set<SqlTypeName>
static final int
static final int
static final int
static final int
static final int
static final List<SqlTypeName>
static final List<SqlTypeName>
static final Set<SqlTypeName>
The possible types of a time frame argument to a function such asTIMESTAMP_DIFF
.static final List<SqlTypeName>
Types that contain time zone information.static final Set<SqlTypeName>
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
boolean
allowsPrecScale
(boolean precision, boolean scale) Returns whether this type can be specified with a given combination of precision and scale.boolean
createLiteral
(Object o, SqlParserPos pos) static @Nullable SqlTypeName
Looks up a type name from its name.int
Deprecated.org.apache.calcite.avatica.util.TimeUnit
ReturnsSECOND
for bothHOUR TO SECOND
andSECOND
.@Nullable SqlTypeFamily
Gets the SqlTypeFamily containing this SqlTypeName.int
Returns the ordinal fromTypes
corresponding to this SqlTypeName.@Nullable Object
getLimit
(boolean sign, SqlTypeName.Limit limit, boolean beyond, int precision, int scale) Returns the limit of this datatype.int
Deprecated.int
Deprecated.UseRelDataTypeSystem.getMinScale(SqlTypeName)
but return Integer.MIN_VALUE if scale is unsupported.getName()
Returns the name of this type.static @Nullable SqlTypeName
getNameForJdbcType
(int jdbcType) Gets the SqlTypeName corresponding to a JDBC type.Returns the name of this type, with underscores converted to spaces, for example "TIMESTAMP WITH LOCAL TIME ZONE", "DATE".org.apache.calcite.avatica.util.TimeUnit
ReturnsHOUR
forHOUR TO SECOND
andHOUR
,SECOND
forSECOND
.boolean
boolean
static SqlTypeName
Returns the SqlTypeName value whose name orgetSpaceName()
matches the given name, or throwsIllegalArgumentException
; never returns null.static SqlTypeName
Returns the enum constant of this type with the specified name.static SqlTypeName[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
BOOLEAN
-
TINYINT
-
SMALLINT
-
INTEGER
-
BIGINT
-
DECIMAL
-
FLOAT
-
REAL
-
DOUBLE
-
DATE
-
TIME
-
TIME_WITH_LOCAL_TIME_ZONE
-
TIME_TZ
-
TIMESTAMP
-
TIMESTAMP_WITH_LOCAL_TIME_ZONE
-
TIMESTAMP_TZ
-
INTERVAL_YEAR
-
INTERVAL_YEAR_MONTH
-
INTERVAL_MONTH
-
INTERVAL_DAY
-
INTERVAL_DAY_HOUR
-
INTERVAL_DAY_MINUTE
-
INTERVAL_DAY_SECOND
-
INTERVAL_HOUR
-
INTERVAL_HOUR_MINUTE
-
INTERVAL_HOUR_SECOND
-
INTERVAL_MINUTE
-
INTERVAL_MINUTE_SECOND
-
INTERVAL_SECOND
-
CHAR
-
VARCHAR
-
BINARY
-
VARBINARY
-
NULL
-
UNKNOWN
-
ANY
-
SYMBOL
-
MULTISET
-
ARRAY
-
MAP
-
DISTINCT
-
STRUCTURED
-
ROW
-
OTHER
-
CURSOR
-
COLUMN_LIST
-
DYNAMIC_STAR
-
GEOMETRY
Spatial type. Though not standard, it is common to several DBs, so we do not flag it 'special' (internal). -
MEASURE
-
FUNCTION
-
SARG
-
-
Field Details
-
MAX_DATETIME_PRECISION
public static final int MAX_DATETIME_PRECISION- See Also:
-
DEFAULT_INTERVAL_START_PRECISION
public static final int DEFAULT_INTERVAL_START_PRECISION- See Also:
-
DEFAULT_INTERVAL_FRACTIONAL_SECOND_PRECISION
public static final int DEFAULT_INTERVAL_FRACTIONAL_SECOND_PRECISION- See Also:
-
MIN_INTERVAL_START_PRECISION
public static final int MIN_INTERVAL_START_PRECISION- See Also:
-
MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION
public static final int MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION- See Also:
-
MAX_INTERVAL_START_PRECISION
public static final int MAX_INTERVAL_START_PRECISION- See Also:
-
MAX_INTERVAL_FRACTIONAL_SECOND_PRECISION
public static final int MAX_INTERVAL_FRACTIONAL_SECOND_PRECISION- See Also:
-
ALL_TYPES
-
BOOLEAN_TYPES
-
BINARY_TYPES
-
INT_TYPES
-
EXACT_TYPES
-
APPROX_TYPES
-
NUMERIC_TYPES
-
FRACTIONAL_TYPES
-
CHAR_TYPES
-
STRING_TYPES
-
GEOMETRY_TYPES
-
DATETIME_TYPES
-
TZ_TYPES
Types that contain time zone information. -
YEAR_INTERVAL_TYPES
-
DAY_INTERVAL_TYPES
-
INTERVAL_TYPES
-
TIME_FRAME_TYPES
The possible types of a time frame argument to a function such asTIMESTAMP_DIFF
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
get
Looks up a type name from its name.- Returns:
- Type name, or null if not found
-
lookup
Returns the SqlTypeName value whose name orgetSpaceName()
matches the given name, or throwsIllegalArgumentException
; never returns null. -
allowsNoPrecNoScale
public boolean allowsNoPrecNoScale() -
allowsPrecNoScale
public boolean allowsPrecNoScale() -
allowsPrec
public boolean allowsPrec() -
allowsScale
public boolean allowsScale() -
allowsPrecScale
public boolean allowsPrecScale(boolean precision, boolean scale) Returns whether this type can be specified with a given combination of precision and scale. For example,Varchar.allowsPrecScale(true, false)
returnstrue
, because the VARCHAR type allows a precision parameter, as inVARCHAR(10)
.Varchar.allowsPrecScale(true, true)
returnsfalse
, because the VARCHAR type does not allow a precision and a scale parameter, as inVARCHAR(10, 4)
.allowsPrecScale(false, true)
returnsfalse
for every type.
- Parameters:
precision
- Whether the precision/length field is part of the type specificationscale
- Whether the scale field is part of the type specification- Returns:
- Whether this combination of precision/scale is valid
-
isSpecial
public boolean isSpecial() -
getJdbcOrdinal
public int getJdbcOrdinal()Returns the ordinal fromTypes
corresponding to this SqlTypeName. -
getDefaultScale
Deprecated.UseRelDataTypeSystem.getDefaultScale(SqlTypeName)
but return Integer.MIN_VALUE if scale is unsupported.Returns the default scale for this type if supported, otherwise -1 if scale is either unsupported or must be specified explicitly. -
getFamily
Gets the SqlTypeFamily containing this SqlTypeName.- Returns:
- containing family, or null for none (SYMBOL, DISTINCT, STRUCTURED, ROW, OTHER)
-
getNameForJdbcType
Gets the SqlTypeName corresponding to a JDBC type.- Parameters:
jdbcType
- the JDBC type of interest- Returns:
- corresponding SqlTypeName, or null if the type is not known
-
getLimit
public @Nullable Object getLimit(boolean sign, SqlTypeName.Limit limit, boolean beyond, int precision, int scale) Returns the limit of this datatype. For example,Datatype limits Datatype sign limit beyond precision scale Returns Integer true true false -1 -1 2147483647 (2 ^ 31 -1 = MAXINT) Integer true true true -1 -1 2147483648 (2 ^ 31 = MAXINT + 1) Integer false true false -1 -1 -2147483648 (-2 ^ 31 = MININT) Boolean true true false -1 -1 TRUE Varchar true true false 10 -1 'ZZZZZZZZZZ' - Parameters:
sign
- If true, returns upper limit, otherwise lower limitlimit
- If true, returns value at or near to overflow; otherwise value at or near to underflowbeyond
- If true, returns the value just beyond the limit, otherwise the value at the limitprecision
- Precision, or -1 if not applicablescale
- Scale, or -1 if not applicable- Returns:
- Limit value
-
getMinPrecision
Deprecated.Returns the minimum precision (or length) allowed for this type, or -1 if precision/length are not applicable for this type.- Returns:
- Minimum allowed precision
-
getMinScale
Deprecated.UseRelDataTypeSystem.getMinScale(SqlTypeName)
but return Integer.MIN_VALUE if scale is unsupported.Returns the minimum scale (or fractional second precision in the case of intervals) allowed for this type, or -1 if scale are not applicable for this type.- Returns:
- Minimum allowed scale
-
getStartUnit
public org.apache.calcite.avatica.util.TimeUnit getStartUnit()ReturnsHOUR
forHOUR TO SECOND
andHOUR
,SECOND
forSECOND
. -
getEndUnit
public org.apache.calcite.avatica.util.TimeUnit getEndUnit()ReturnsSECOND
for bothHOUR TO SECOND
andSECOND
. -
isYearMonth
public boolean isYearMonth() -
createLiteral
-
getName
Returns the name of this type. -
getSpaceName
Returns the name of this type, with underscores converted to spaces, for example "TIMESTAMP WITH LOCAL TIME ZONE", "DATE".
-
RelDataTypeSystem.getDefaultScale(SqlTypeName)
but return Integer.MIN_VALUE if scale is unsupported.