Package org.apache.calcite.sql.type
Class SqlTypeFactoryImpl
java.lang.Object
org.apache.calcite.rel.type.RelDataTypeFactoryImpl
org.apache.calcite.sql.type.SqlTypeFactoryImpl
- All Implemented Interfaces:
RelDataTypeFactory
- Direct Known Subclasses:
JavaTypeFactoryImpl
SqlTypeFactoryImpl provides a default implementation of
RelDataTypeFactory
which supports SQL types.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.rel.type.RelDataTypeFactoryImpl
RelDataTypeFactoryImpl.JavaType
Nested classes/interfaces inherited from interface org.apache.calcite.rel.type.RelDataTypeFactory
RelDataTypeFactory.Builder, RelDataTypeFactory.FieldInfo, RelDataTypeFactory.FieldInfoBuilder
-
Field Summary
Fields inherited from class org.apache.calcite.rel.type.RelDataTypeFactoryImpl
typeSystem
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RelDataType
canonize
(RelDataType type) Registers a type, or returns the existing type if it is already registered.createArrayType
(RelDataType elementType, long maxCardinality) Creates an array type.createMapType
(RelDataType keyType, RelDataType valueType) Creates a map type.createMeasureType
(RelDataType valueType) Creates a measure type.createMultisetType
(RelDataType type, long maxCardinality) Creates a multiset type.createSqlIntervalType
(SqlIntervalQualifier intervalQualifier) Creates a SQL interval type.createSqlType
(SqlTypeName typeName) Creates a SQL type with no precision or scale.createSqlType
(SqlTypeName typeName, int precision) Creates a SQL type with length (precision) but no scale.createSqlType
(SqlTypeName typeName, int precision, int scale) Creates a SQL type with precision and scale.createTypeWithCharsetAndCollation
(RelDataType type, Charset charset, SqlCollation collation) Creates a type that is the same as another type but with possibly different charset or collation.createTypeWithNullability
(RelDataType type, boolean nullable) Creates a type that is the same as another type but with possibly different nullability.Creates a SQL type that represents the "unknown" type.@Nullable RelDataType
leastRestrictive
(List<RelDataType> types) Returns the most general of a set of types (that is, one type to which they can all be cast), or null if conversion is not possible.Methods inherited from class org.apache.calcite.rel.type.RelDataTypeFactoryImpl
builder, canonize, canonize, copyType, createDecimalProduct, createDecimalQuotient, createJavaType, createJoinType, createStructType, createStructType, createStructType, createStructType, decimalOf, getDefaultCharset, getTypeSystem, isJavaType, leastRestrictiveArrayMultisetType, leastRestrictiveMapType, leastRestrictiveStructuredType, useDoubleMultiplication
-
Constructor Details
-
SqlTypeFactoryImpl
-
-
Method Details
-
createSqlType
Description copied from interface:RelDataTypeFactory
Creates a SQL type with no precision or scale.- Parameters:
typeName
- Name of the type, for exampleSqlTypeName.BOOLEAN
, never null- Returns:
- canonical type descriptor
-
createSqlType
Description copied from interface:RelDataTypeFactory
Creates a SQL type with length (precision) but no scale.- Parameters:
typeName
- Name of the type, for exampleSqlTypeName.VARCHAR
. Never null.precision
- Maximum length of the value (non-numeric types) or the precision of the value (numeric/datetime types). Must be non-negative orRelDataType.PRECISION_NOT_SPECIFIED
.- Returns:
- canonical type descriptor
-
createSqlType
Description copied from interface:RelDataTypeFactory
Creates a SQL type with precision and scale.- Parameters:
typeName
- Name of the type, for exampleSqlTypeName.DECIMAL
. Never null.precision
- Precision of the value. Must be non-negative orRelDataType.PRECISION_NOT_SPECIFIED
.scale
- scale of the values, i.e. the number of decimal places to shift the value. For example, a NUMBER(10,3) value of "123.45" is represented "123450" (that is, multiplied by 10^3). A negative scale is valid.- Returns:
- canonical type descriptor
-
createUnknownType
Description copied from interface:RelDataTypeFactory
Creates a SQL type that represents the "unknown" type. It is only equal to itself, and is distinct from the NULL type.- Returns:
- unknown type
-
createMultisetType
Description copied from interface:RelDataTypeFactory
Creates a multiset type. Multisets are unordered collections of elements.- Parameters:
type
- type of the elements of the multisetmaxCardinality
- maximum collection size, or -1 for unlimited- Returns:
- canonical multiset type descriptor
-
createArrayType
Description copied from interface:RelDataTypeFactory
Creates an array type. Arrays are ordered collections of elements.- Parameters:
elementType
- type of the elements of the arraymaxCardinality
- maximum array size, or -1 for unlimited- Returns:
- canonical array type descriptor
-
createMapType
Description copied from interface:RelDataTypeFactory
Creates a map type. Maps are unordered collections of key/value pairs.- Parameters:
keyType
- type of the keys of the mapvalueType
- type of the values of the map- Returns:
- canonical map type descriptor
-
createMeasureType
Description copied from interface:RelDataTypeFactory
Creates a measure type.- Parameters:
valueType
- type of the values of the measure- Returns:
- canonical measure type descriptor
-
createSqlIntervalType
Description copied from interface:RelDataTypeFactory
Creates a SQL interval type.- Parameters:
intervalQualifier
- contains information if it is a year-month or a day-time interval along with precision information- Returns:
- canonical type descriptor
-
createTypeWithCharsetAndCollation
public RelDataType createTypeWithCharsetAndCollation(RelDataType type, Charset charset, SqlCollation collation) Description copied from interface:RelDataTypeFactory
Creates a type that is the same as another type but with possibly different charset or collation. For types without a concept of charset or collation this function must throw an error.- Parameters:
type
- input typecharset
- charset to assigncollation
- collation to assign- Returns:
- output type, same as input type except with specified charset and collation
-
leastRestrictive
Description copied from interface:RelDataTypeFactory
Returns the most general of a set of types (that is, one type to which they can all be cast), or null if conversion is not possible. The result may be a new type that is less restrictive than any of the input types, e.g.leastRestrictive(INT, NUMERIC(3, 2))
could beNUMERIC(12, 2)
.- Specified by:
leastRestrictive
in interfaceRelDataTypeFactory
- Overrides:
leastRestrictive
in classRelDataTypeFactoryImpl
- Parameters:
types
- input types to be combined using union (not null, not empty)- Returns:
- canonical union type descriptor
-
createTypeWithNullability
Description copied from interface:RelDataTypeFactory
Creates a type that is the same as another type but with possibly different nullability. The output type may be identical to the input type. For type systems without a concept of nullability, the return value is always the same as the input.- Specified by:
createTypeWithNullability
in interfaceRelDataTypeFactory
- Overrides:
createTypeWithNullability
in classRelDataTypeFactoryImpl
- Parameters:
type
- input typenullable
- true to request a nullable type; false to request a NOT NULL type- Returns:
- output type, same as input type except with specified nullability
-
canonize
Description copied from class:RelDataTypeFactoryImpl
Registers a type, or returns the existing type if it is already registered.- Overrides:
canonize
in classRelDataTypeFactoryImpl
-