public interface RelDataTypeFactory
This interface is an example of the
abstract factory pattern.
Any implementation of RelDataTypeFactory must ensure that type
objects are canonical: two types are equal if and only if they are
represented by the same Java object. This reduces memory consumption and
comparison cost.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
RelDataTypeFactory.FieldInfo
Callback which provides enough information to create fields.
|
static class |
RelDataTypeFactory.FieldInfoBuilder
Implementation of
RelDataTypeFactory.FieldInfo that provides a fluid API to build
a list of fields. |
| Modifier and Type | Method and Description |
|---|---|
RelDataTypeFactory.FieldInfoBuilder |
builder()
Creates a
RelDataTypeFactory.FieldInfoBuilder. |
RelDataType |
copyType(RelDataType type)
Duplicates a type, making a deep copy.
|
RelDataType |
createArrayType(RelDataType elementType,
long maxCardinality)
Creates an array type.
|
RelDataType |
createDecimalProduct(RelDataType type1,
RelDataType type2)
Infers the return type of a decimal multiplication.
|
RelDataType |
createDecimalQuotient(RelDataType type1,
RelDataType type2)
Infers the return type of a decimal division.
|
RelDataType |
createJavaType(Class clazz)
Creates a type which corresponds to a Java class.
|
RelDataType |
createJoinType(RelDataType... types)
Creates a cartesian product type.
|
RelDataType |
createMapType(RelDataType keyType,
RelDataType valueType)
Creates a map type.
|
RelDataType |
createMultisetType(RelDataType elementType,
long maxCardinality)
Creates a multiset type.
|
RelDataType |
createSqlIntervalType(SqlIntervalQualifier intervalQualifier)
Creates a SQL interval type.
|
RelDataType |
createSqlType(SqlTypeName typeName)
Creates a SQL type with no precision or scale.
|
RelDataType |
createSqlType(SqlTypeName typeName,
int precision)
Creates a SQL type with length (precision) but no scale.
|
RelDataType |
createSqlType(SqlTypeName typeName,
int precision,
int scale)
Creates a SQL type with precision and scale.
|
RelDataType |
createStructType(List<? extends Map.Entry<String,RelDataType>> fieldList)
Creates a type which represents a structured collection of fieldList,
obtaining the field information from a list of (name, type) pairs.
|
RelDataType |
createStructType(List<RelDataType> typeList,
List<String> fieldNameList)
Creates a type which represents a structured collection of fields, given
lists of the names and types of the fields.
|
RelDataType |
createStructType(RelDataTypeFactory.FieldInfo fieldInfo)
Creates a type which represents a structured collection of fields,
obtaining the field information via a callback.
|
RelDataType |
createTypeWithCharsetAndCollation(RelDataType type,
Charset charset,
SqlCollation collation)
Creates a Type which is the same as another type but with possibly
different charset or collation.
|
RelDataType |
createTypeWithNullability(RelDataType type,
boolean nullable)
Creates a type which is the same as another type but with possibly
different nullability.
|
Charset |
getDefaultCharset() |
RelDataTypeSystem |
getTypeSystem()
Returns the type system.
|
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.
|
boolean |
useDoubleMultiplication(RelDataType type1,
RelDataType type2)
Returns whether a decimal multiplication should be implemented by casting
arguments to double values.
|
RelDataTypeSystem getTypeSystem()
RelDataType createJavaType(Class clazz)
clazz - the Java class used to define the typeRelDataType createJoinType(RelDataType... types)
types - array of types to be joinedRelDataType createStructType(List<RelDataType> typeList, List<String> fieldNameList)
typeList - types of the fieldsfieldNameList - names of the fieldsRelDataType createStructType(RelDataTypeFactory.FieldInfo fieldInfo)
fieldInfo - callback for field informationRelDataType createStructType(List<? extends Map.Entry<String,RelDataType>> fieldList)
fieldList - List of (name, type) pairsRelDataType createArrayType(RelDataType elementType, long maxCardinality)
elementType - type of the elements of the arraymaxCardinality - maximum array size, or -1 for unlimitedRelDataType createMapType(RelDataType keyType, RelDataType valueType)
keyType - type of the keys of the mapvalueType - type of the values of the mapRelDataType createMultisetType(RelDataType elementType, long maxCardinality)
elementType - type of the elements of the multisetmaxCardinality - maximum collection size, or -1 for unlimitedRelDataType copyType(RelDataType type)
type - input typeRelDataType createTypeWithNullability(RelDataType type, boolean nullable)
type - input typenullable - true to request a nullable type; false to request a NOT
NULL typeNullPointerException - if type is nullRelDataType createTypeWithCharsetAndCollation(RelDataType type, Charset charset, SqlCollation collation)
type - input typecharset - charset to assigncollation - collation to assignRelDataType leastRestrictive(List<RelDataType> types)
leastRestrictive(INT, NUMERIC(3, 2)) could be
NUMERIC(12, 2).types - input types to be combined using union (not null, not empty)RelDataType createSqlType(SqlTypeName typeName)
typeName - Name of the type, for example SqlTypeName.BOOLEAN,
never nullRelDataType createSqlType(SqlTypeName typeName, int precision)
typeName - Name of the type, for example SqlTypeName.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 or
RelDataType.PRECISION_NOT_SPECIFIED.RelDataType createSqlType(SqlTypeName typeName, int precision, int scale)
typeName - Name of the type, for example SqlTypeName.DECIMAL.
Never null.precision - Precision of the value.
Must be non-negative or
RelDataType.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.RelDataType createSqlIntervalType(SqlIntervalQualifier intervalQualifier)
intervalQualifier - contains information if it is a year-month or a
day-time interval along with precision informationRelDataType createDecimalProduct(RelDataType type1, RelDataType type2)
type1 - type of the first operandtype2 - type of the second operandboolean useDoubleMultiplication(RelDataType type1, RelDataType type2)
Pre-condition: createDecimalProduct(type1, type2) != null
RelDataType createDecimalQuotient(RelDataType type1, RelDataType type2)
type1 - type of the first operandtype2 - type of the second operandRelDataTypeFactory.FieldInfoBuilder builder()
RelDataTypeFactory.FieldInfoBuilder.Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.