public abstract class RelDataTypeFactoryImpl extends java.lang.Object implements RelDataTypeFactory
RelDataTypeFactory
.Modifier and Type | Class and Description |
---|---|
class |
RelDataTypeFactoryImpl.JavaType
Type which is based upon a Java class.
|
private static class |
RelDataTypeFactoryImpl.Key
Key to the data type cache.
|
RelDataTypeFactory.Builder, RelDataTypeFactory.FieldInfo, RelDataTypeFactory.FieldInfoBuilder
Modifier and Type | Field and Description |
---|---|
private static com.google.common.cache.LoadingCache<java.lang.Object,RelDataType> |
CACHE
Global cache.
|
private static java.util.Map<java.lang.Class,RelDataTypeFamily> |
CLASS_FAMILIES |
protected RelDataTypeSystem |
typeSystem |
Modifier | Constructor and Description |
---|---|
protected |
RelDataTypeFactoryImpl(RelDataTypeSystem typeSystem)
Creates a type factory.
|
Modifier and Type | Method and Description |
---|---|
private static void |
addFields(RelDataType type,
java.util.List<RelDataTypeField> fieldList)
Adds all fields in
type to fieldList ,
renumbering the fields (if necessary) to ensure that their index
matches their position in the list. |
RelDataTypeFactory.FieldInfoBuilder |
builder()
Creates a
RelDataTypeFactory.FieldInfoBuilder . |
protected RelDataType |
canonize(RelDataType type)
Registers a type, or returns the existing type if it is already
registered.
|
protected RelDataType |
canonize(StructKind kind,
java.util.List<java.lang.String> names,
java.util.List<RelDataType> types) |
protected RelDataType |
canonize(StructKind kind,
java.util.List<java.lang.String> names,
java.util.List<RelDataType> types,
boolean nullable)
Looks up a type using a temporary key, and if not present, creates
a permanent key and type.
|
private RelDataType |
copyRecordType(RelRecordType type,
boolean ignoreNullable,
boolean nullable) |
private RelDataType |
copySimpleType(RelDataType type,
boolean nullable) |
RelDataType |
copyType(RelDataType type)
Duplicates a type, making a deep copy.
|
RelDataType |
createDecimalProduct(RelDataType type1,
RelDataType type2)
Infers the return type of a decimal multiplication.
|
RelDataType |
createDecimalQuotient(RelDataType type1,
RelDataType type2)
Rules:
Let p1, s1 be the precision and scale of the first operand
Let p2, s2 be the precision and scale of the second operand
Let p, s be the precision and scale of the result
Let d be the number of whole digits in the result
Then the result type is a decimal with:
d = p1 - s1 + s2
s < max(6, s1 + p2 + 1)
p = d + s
p and s are capped at their maximum values
|
RelDataType |
createJavaType(java.lang.Class clazz)
Creates a type that corresponds to a Java class.
|
RelDataType |
createJoinType(RelDataType... types)
Creates a cartesian product type.
|
RelDataType |
createStructType(java.util.List<? extends java.util.Map.Entry<java.lang.String,RelDataType>> fieldList)
Creates a type that represents a structured collection of fieldList,
obtaining the field information from a list of (name, type) pairs.
|
private RelDataType |
createStructType(java.util.List<? extends java.util.Map.Entry<java.lang.String,RelDataType>> fieldList,
boolean nullable) |
RelDataType |
createStructType(java.util.List<RelDataType> typeList,
java.util.List<java.lang.String> fieldNameList)
Creates a type that represents a structured collection of fields.
|
RelDataType |
createStructType(RelDataTypeFactory.FieldInfo fieldInfo)
Creates a type that represents a structured collection of fields,
obtaining the field information via a callback.
|
RelDataType |
createStructType(StructKind kind,
java.util.List<RelDataType> typeList,
java.util.List<java.lang.String> fieldNameList)
Creates a type that represents a structured collection of fields, given
lists of the names and types of the fields.
|
private RelDataType |
createStructType(StructKind kind,
java.util.List<RelDataType> typeList,
java.util.List<java.lang.String> fieldNameList,
boolean nullable) |
RelDataType |
createTypeWithNullability(RelDataType type,
boolean nullable)
Creates a type that is the same as another type but with possibly
different nullability.
|
private java.util.List<RelDataTypeFieldImpl> |
fieldsOf(java.lang.Class clazz) |
java.nio.charset.Charset |
getDefaultCharset() |
private static java.util.List<RelDataTypeField> |
getFieldList(java.util.List<RelDataType> types)
Returns a list of the fields in a list of types.
|
private static void |
getTypeList(com.google.common.collect.ImmutableList<RelDataType> inTypes,
java.util.List<RelDataType> flatTypes)
Returns a list of all atomic types in a list.
|
RelDataTypeSystem |
getTypeSystem()
Returns the type system.
|
static boolean |
isJavaType(RelDataType t) |
private static RelDataType |
keyToType(java.lang.Object k) |
RelDataType |
leastRestrictive(java.util.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 RelDataType |
leastRestrictiveStructuredType(java.util.List<RelDataType> types) |
boolean |
useDoubleMultiplication(RelDataType type1,
RelDataType type2)
Returns whether a decimal multiplication should be implemented by casting
arguments to double values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createArrayType, createMapType, createMultisetType, createSqlIntervalType, createSqlType, createSqlType, createSqlType, createTypeWithCharsetAndCollation, createUnknownType
private static final com.google.common.cache.LoadingCache<java.lang.Object,RelDataType> CACHE
private static final java.util.Map<java.lang.Class,RelDataTypeFamily> CLASS_FAMILIES
protected final RelDataTypeSystem typeSystem
protected RelDataTypeFactoryImpl(RelDataTypeSystem typeSystem)
private static RelDataType keyToType(@Nonnull java.lang.Object k)
public RelDataTypeSystem getTypeSystem()
RelDataTypeFactory
getTypeSystem
in interface RelDataTypeFactory
public RelDataType createJavaType(java.lang.Class clazz)
RelDataTypeFactory
createJavaType
in interface RelDataTypeFactory
clazz
- the Java class used to define the typepublic RelDataType createJoinType(RelDataType... types)
RelDataTypeFactory
createJoinType
in interface RelDataTypeFactory
types
- array of types to be joinedpublic RelDataType createStructType(java.util.List<RelDataType> typeList, java.util.List<java.lang.String> fieldNameList)
RelDataTypeFactory
createStructType(StructKind.FULLY_QUALIFIED, typeList,
fieldNameList)
.createStructType
in interface RelDataTypeFactory
public RelDataType createStructType(StructKind kind, java.util.List<RelDataType> typeList, java.util.List<java.lang.String> fieldNameList)
RelDataTypeFactory
createStructType
in interface RelDataTypeFactory
kind
- Name resolution policytypeList
- types of the fieldsfieldNameList
- names of the fieldsprivate RelDataType createStructType(StructKind kind, java.util.List<RelDataType> typeList, java.util.List<java.lang.String> fieldNameList, boolean nullable)
public RelDataType createStructType(RelDataTypeFactory.FieldInfo fieldInfo)
RelDataTypeFactory
createStructType
in interface RelDataTypeFactory
fieldInfo
- callback for field informationpublic final RelDataType createStructType(java.util.List<? extends java.util.Map.Entry<java.lang.String,RelDataType>> fieldList)
RelDataTypeFactory
createStructType
in interface RelDataTypeFactory
fieldList
- List of (name, type) pairsprivate RelDataType createStructType(java.util.List<? extends java.util.Map.Entry<java.lang.String,RelDataType>> fieldList, boolean nullable)
public RelDataType leastRestrictive(java.util.List<RelDataType> types)
RelDataTypeFactory
leastRestrictive(INT, NUMERIC(3, 2))
could be
NUMERIC(12, 2)
.leastRestrictive
in interface RelDataTypeFactory
types
- input types to be combined using union (not null, not empty)protected RelDataType leastRestrictiveStructuredType(java.util.List<RelDataType> types)
private RelDataType copySimpleType(RelDataType type, boolean nullable)
private RelDataType copyRecordType(RelRecordType type, boolean ignoreNullable, boolean nullable)
public RelDataType copyType(RelDataType type)
RelDataTypeFactory
copyType
in interface RelDataTypeFactory
type
- input typepublic RelDataType createTypeWithNullability(RelDataType type, boolean nullable)
RelDataTypeFactory
createTypeWithNullability
in interface RelDataTypeFactory
type
- input typenullable
- true to request a nullable type; false to request a NOT
NULL typeprotected RelDataType canonize(RelDataType type)
java.lang.NullPointerException
- if type is nullprotected RelDataType canonize(StructKind kind, java.util.List<java.lang.String> names, java.util.List<RelDataType> types, boolean nullable)
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.
protected RelDataType canonize(StructKind kind, java.util.List<java.lang.String> names, java.util.List<RelDataType> types)
private static java.util.List<RelDataTypeField> getFieldList(java.util.List<RelDataType> types)
private static void getTypeList(com.google.common.collect.ImmutableList<RelDataType> inTypes, java.util.List<RelDataType> flatTypes)
private static void addFields(RelDataType type, java.util.List<RelDataTypeField> fieldList)
type
to fieldList
,
renumbering the fields (if necessary) to ensure that their index
matches their position in the list.public static boolean isJavaType(RelDataType t)
private java.util.List<RelDataTypeFieldImpl> fieldsOf(java.lang.Class clazz)
public RelDataType createDecimalProduct(RelDataType type1, RelDataType type2)
Implement RelDataTypeFactory with SQL 2003 compliant behavior. Let p1, s1 be the precision and scale of the first operand Let p2, s2 be the precision and scale of the second operand Let p, s be the precision and scale of the result, Then the result type is a decimal with:
p and s are capped at their maximum values
createDecimalProduct
in interface RelDataTypeFactory
type1
- type of the first operandtype2
- type of the second operandSQL:2003 Part 2 Section 6.26
public boolean useDoubleMultiplication(RelDataType type1, RelDataType type2)
RelDataTypeFactory
Pre-condition: createDecimalProduct(type1, type2) != null
useDoubleMultiplication
in interface RelDataTypeFactory
public RelDataType createDecimalQuotient(RelDataType type1, RelDataType type2)
createDecimalQuotient
in interface RelDataTypeFactory
type1
- type of the first operandtype2
- type of the second operandSQL:2003 Part 2 Section 6.26
public java.nio.charset.Charset getDefaultCharset()
getDefaultCharset
in interface RelDataTypeFactory
Charset
for string typespublic RelDataTypeFactory.FieldInfoBuilder builder()
RelDataTypeFactory
RelDataTypeFactory.FieldInfoBuilder
.
But since FieldInfoBuilder
is deprecated, we recommend that you use
its base class RelDataTypeFactory.Builder
, which is not deprecated.builder
in interface RelDataTypeFactory
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.