Package org.apache.calcite.rel.type
Class RelDataTypeFactoryImpl
java.lang.Object
org.apache.calcite.rel.type.RelDataTypeFactoryImpl
- All Implemented Interfaces:
RelDataTypeFactory
- Direct Known Subclasses:
SqlTypeFactoryImpl
Abstract base for implementations of
RelDataTypeFactory
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Type which is based upon a Java class.Nested classes/interfaces inherited from interface org.apache.calcite.rel.type.RelDataTypeFactory
RelDataTypeFactory.Builder, RelDataTypeFactory.FieldInfo, RelDataTypeFactory.FieldInfoBuilder
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RelDataTypeFactoryImpl
(RelDataTypeSystem typeSystem) Creates a type factory. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Creates aRelDataTypeFactory.FieldInfoBuilder
.protected RelDataType
canonize
(RelDataType type) Registers a type, or returns the existing type if it is already registered.protected RelDataType
canonize
(StructKind kind, List<String> names, List<RelDataType> types) protected RelDataType
canonize
(StructKind kind, List<String> names, List<RelDataType> types, boolean nullable) Looks up a type using a temporary key, and if not present, creates a permanent key and type.copyType
(RelDataType type) Duplicates a type, making a deep copy.@Nullable RelDataType
createDecimalProduct
(RelDataType type1, RelDataType type2) Deprecated.@Nullable RelDataType
createDecimalQuotient
(RelDataType type1, RelDataType type2) Deprecated.createJavaType
(Class clazz) Creates a type that corresponds to a Java class.createJoinType
(RelDataType... types) Creates a cartesian product type.final RelDataType
createStructType
(List<? extends Map.Entry<String, RelDataType>> fieldList) Creates a type that represents a structured collection of fieldList, obtaining the field information from a list of (name, type) pairs.createStructType
(List<RelDataType> typeList, List<String> fieldNameList) Creates a type that represents a structured collection of fields.createStructType
(RelDataTypeFactory.FieldInfo fieldInfo) Creates a type that represents a structured collection of fields, obtaining the field information via a callback.createStructType
(StructKind kind, List<RelDataType> typeList, List<String> fieldNameList) Creates a type that represents a structured collection of fields, given lists of the names and types of the fields.createTypeWithNullability
(RelDataType type, boolean nullable) Creates a type that is the same as another type but with possibly different nullability.decimalOf
(RelDataType type) Create a decimal type equivalent to the numerictype
, this is related to specific system implementation, you can override this logic if it is required.Returns the defaultCharset
(valid if this is a string type).Returns the type system.static boolean
@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.protected @Nullable RelDataType
leastRestrictiveArrayMultisetType
(List<RelDataType> types, SqlTypeName sqlTypeName) protected @Nullable RelDataType
leastRestrictiveMapType
(List<RelDataType> types, SqlTypeName sqlTypeName) protected @Nullable RelDataType
boolean
useDoubleMultiplication
(RelDataType type1, RelDataType type2) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.rel.type.RelDataTypeFactory
createArrayType, createMapType, createMeasureType, createMultisetType, createSqlIntervalType, createSqlType, createSqlType, createSqlType, createTypeWithCharsetAndCollation, createUnknownType
-
Field Details
-
typeSystem
-
-
Constructor Details
-
RelDataTypeFactoryImpl
Creates a type factory.
-
-
Method Details
-
getTypeSystem
Description copied from interface:RelDataTypeFactory
Returns the type system.- Specified by:
getTypeSystem
in interfaceRelDataTypeFactory
- Returns:
- Type system
-
createJavaType
Description copied from interface:RelDataTypeFactory
Creates a type that corresponds to a Java class.- Specified by:
createJavaType
in interfaceRelDataTypeFactory
- Parameters:
clazz
- the Java class used to define the type- Returns:
- canonical Java type descriptor
-
createJoinType
Description copied from interface:RelDataTypeFactory
Creates a cartesian product type.- Specified by:
createJoinType
in interfaceRelDataTypeFactory
- Parameters:
types
- array of types to be joined- Returns:
- canonical join type descriptor
-
createStructType
Description copied from interface:RelDataTypeFactory
Creates a type that represents a structured collection of fields. Shorthand forcreateStructType(StructKind.FULLY_QUALIFIED, typeList, fieldNameList)
.- Specified by:
createStructType
in interfaceRelDataTypeFactory
-
createStructType
public RelDataType createStructType(StructKind kind, List<RelDataType> typeList, List<String> fieldNameList) Description copied from interface:RelDataTypeFactory
Creates a type that represents a structured collection of fields, given lists of the names and types of the fields.- Specified by:
createStructType
in interfaceRelDataTypeFactory
- Parameters:
kind
- Name resolution policytypeList
- types of the fieldsfieldNameList
- names of the fields- Returns:
- canonical struct type descriptor
-
createStructType
Description copied from interface:RelDataTypeFactory
Creates a type that represents a structured collection of fields, obtaining the field information via a callback.- Specified by:
createStructType
in interfaceRelDataTypeFactory
- Parameters:
fieldInfo
- callback for field information- Returns:
- canonical struct type descriptor
-
createStructType
Description copied from interface:RelDataTypeFactory
Creates a type that represents a structured collection of fieldList, obtaining the field information from a list of (name, type) pairs.- Specified by:
createStructType
in interfaceRelDataTypeFactory
- Parameters:
fieldList
- List of (name, type) pairs- Returns:
- canonical struct type descriptor
-
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
- Parameters:
types
- input types to be combined using union (not null, not empty)- Returns:
- canonical union type descriptor
-
leastRestrictiveStructuredType
-
leastRestrictiveArrayMultisetType
protected @Nullable RelDataType leastRestrictiveArrayMultisetType(List<RelDataType> types, SqlTypeName sqlTypeName) -
leastRestrictiveMapType
protected @Nullable RelDataType leastRestrictiveMapType(List<RelDataType> types, SqlTypeName sqlTypeName) -
copyType
Description copied from interface:RelDataTypeFactory
Duplicates a type, making a deep copy. Normally, this is a no-op, since canonical type objects are returned. However, it is useful when copying a type from one factory to another.- Specified by:
copyType
in interfaceRelDataTypeFactory
- Parameters:
type
- input type- Returns:
- output type, a new object equivalent to input type
-
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
- 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
Registers a type, or returns the existing type if it is already registered.- Throws:
NullPointerException
- if type is null
-
canonize
protected RelDataType canonize(StructKind kind, List<String> names, List<RelDataType> types, boolean nullable) Looks up a type using a temporary key, and if not present, creates a permanent key and type.This approach allows us to use a cheap temporary key. A permanent key is more expensive, because it must be immutable and not hold references into other data structures.
-
canonize
-
isJavaType
-
createDecimalProduct
Deprecated.Delegates toRelDataTypeSystem.deriveDecimalMultiplyType(RelDataTypeFactory, RelDataType, RelDataType)
to get the return type for the operation.- Specified by:
createDecimalProduct
in interfaceRelDataTypeFactory
- Parameters:
type1
- type of the first operandtype2
- type of the second operand- Returns:
- the result type for a decimal multiplication, or null if decimal multiplication should not be applied to the operands.
-
useDoubleMultiplication
Deprecated.Delegates toRelDataTypeSystem.shouldUseDoubleMultiplication(RelDataTypeFactory, RelDataType, RelDataType)
to get if double should be used for multiplication.- Specified by:
useDoubleMultiplication
in interfaceRelDataTypeFactory
-
createDecimalQuotient
@Deprecated public @Nullable RelDataType createDecimalQuotient(RelDataType type1, RelDataType type2) Deprecated.Delegates toRelDataTypeSystem.deriveDecimalDivideType(RelDataTypeFactory, RelDataType, RelDataType)
to get the return type for the operation.- Specified by:
createDecimalQuotient
in interfaceRelDataTypeFactory
- Parameters:
type1
- type of the first operandtype2
- type of the second operand- Returns:
- the result type for a decimal division, or null if decimal division should not be applied to the operands.
-
decimalOf
Description copied from interface:RelDataTypeFactory
Create a decimal type equivalent to the numerictype
, this is related to specific system implementation, you can override this logic if it is required.- Specified by:
decimalOf
in interfaceRelDataTypeFactory
- Parameters:
type
- the numeric type to create decimal type with- Returns:
- decimal equivalence of the numeric type.
-
getDefaultCharset
Description copied from interface:RelDataTypeFactory
Returns the defaultCharset
(valid if this is a string type).- Specified by:
getDefaultCharset
in interfaceRelDataTypeFactory
-
builder
Description copied from interface:RelDataTypeFactory
Creates aRelDataTypeFactory.FieldInfoBuilder
. But sinceFieldInfoBuilder
is deprecated, we recommend that you use its base classRelDataTypeFactory.Builder
, which is not deprecated.- Specified by:
builder
in interfaceRelDataTypeFactory
-