public abstract class RelDataTypeImpl extends Object implements RelDataType, RelDataTypeFamily
RelDataType.
Identity is based upon the digest field, which each derived class
should set during construction.
| Modifier and Type | Field and Description |
|---|---|
protected @Nullable String |
digest |
protected @Nullable List<RelDataTypeField> |
fieldList |
static String |
NON_NULLABLE_SUFFIX
Suffix for the digests of non-nullable types.
|
PRECISION_NOT_SPECIFIED, SCALE_NOT_SPECIFIED| Modifier | Constructor and Description |
|---|---|
protected |
RelDataTypeImpl()
Default constructor, to allow derived classes such as
BasicSqlType to be Serializable. |
protected |
RelDataTypeImpl(@Nullable List<? extends RelDataTypeField> fieldList)
Creates a RelDataTypeImpl.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
computeDigest()
Computes the digest field.
|
boolean |
equals(@Nullable Object obj) |
static @Nullable RelDataTypeField |
extra(RelDataType rowType)
Returns the "extra" field in a row type whose presence signals that
fields will come into existence just by asking for them.
|
protected abstract void |
generateTypeString(StringBuilder sb,
boolean withDetail)
Generates a string representation of this type.
|
@Nullable Charset |
getCharset()
Gets this type's character set, or null if this type cannot carry a
character set or has no character set defined.
|
@Nullable SqlCollation |
getCollation()
Gets this type's collation, or null if this type cannot carry a collation
or has no collation defined.
|
RelDataTypeComparability |
getComparability()
Returns the category of comparison operators that make sense when applied
to values of this type.
|
@Nullable RelDataType |
getComponentType()
Gets the component type if this type is a collection, otherwise null.
|
RelDataTypeFamily |
getFamily()
Gets a canonical object representing the family of this type.
|
@Nullable RelDataTypeField |
getField(String fieldName,
boolean caseSensitive,
boolean elideRecord)
Looks up a field by name.
|
int |
getFieldCount()
Returns the number of fields in a struct type.
|
List<RelDataTypeField> |
getFieldList()
Gets the fields in a struct type.
|
protected @Nullable Map<String,RelDataTypeField> |
getFieldMap()
Returns a map from field names to fields.
|
List<String> |
getFieldNames()
Returns the names of the fields in a struct type.
|
String |
getFullTypeString()
Gets a string representation of this type with full detail such as
character set and nullability.
|
@Nullable SqlIntervalQualifier |
getIntervalQualifier()
Gets this type's interval qualifier, or null if this is not an interval
type.
|
@Nullable RelDataType |
getKeyType()
Gets the key type if this type is a map, otherwise null.
|
RelDataTypePrecedenceList |
getPrecedenceList()
Returns the precedence list for this type.
|
int |
getPrecision()
Gets the JDBC-defined precision for values of this type.
|
int |
getScale()
Gets the scale of this type.
|
@Nullable SqlIdentifier |
getSqlIdentifier()
Gets the
SqlIdentifier associated with this type. |
SqlTypeName |
getSqlTypeName()
Gets the
SqlTypeName of this type. |
StructKind |
getStructKind()
Returns the rule for resolving the fields of a structured type,
or
StructKind.NONE if this is not a structured type. |
@Nullable RelDataType |
getValueType()
Gets the value type if this type is a map, otherwise null.
|
int |
hashCode() |
boolean |
isDynamicStruct()
Returns whether this type has dynamic structure (for "schema-on-read"
table).
|
boolean |
isNullable()
Queries whether this type allows null values.
|
boolean |
isStruct()
Queries whether this is a structured type.
|
static RelProtoDataType |
proto(RelDataType protoType)
Returns an implementation of
RelProtoDataType
that copies a given type using the given type factory. |
static RelProtoDataType |
proto(SqlTypeName typeName,
boolean nullable)
Returns a
RelProtoDataType
that will create a type typeName. |
static RelProtoDataType |
proto(SqlTypeName typeName,
int precision,
boolean nullable)
Returns a
RelProtoDataType
that will create a type typeName(precision). |
static RelProtoDataType |
proto(SqlTypeName typeName,
int precision,
int scale,
boolean nullable)
Returns a
RelProtoDataType
that will create a type typeName(precision, scale). |
String |
toString()
Gets a string representation of this type without detail such as
character set and nullability.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitequalsSansFieldNamespublic static final String NON_NULLABLE_SUFFIX
protected final @Nullable List<RelDataTypeField> fieldList
protected @Nullable String digest
protected RelDataTypeImpl(@Nullable List<? extends RelDataTypeField> fieldList)
fieldList - List of fieldsprotected RelDataTypeImpl()
BasicSqlType to be Serializable.
(The serialization specification says that a class can be serializable even if its base class is not serializable, provided that the base class has a public or protected zero-args constructor.)
public @Nullable RelDataTypeField getField(String fieldName, boolean caseSensitive, boolean elideRecord)
RelDataTypeNOTE: Be careful choosing the value of caseSensitive:
true if you are sure that the field name is
internally generated.false is almost certainly wrong.getField in interface RelDataTypefieldName - Name of field to findcaseSensitive - Whether match is case-sensitiveelideRecord - Whether to find fields nested within recordsprotected @Nullable Map<String,RelDataTypeField> getFieldMap()
Matching is case-sensitive.
If several fields have the same name, the map contains the first.
A dynamic star field is indexed
under its own name and "" (the empty string).
If the map is null, the type must do lookup the long way.
public List<RelDataTypeField> getFieldList()
RelDataTypegetFieldList in interface RelDataTypepublic List<String> getFieldNames()
RelDataTypegetFieldNames in interface RelDataTypepublic int getFieldCount()
RelDataTypeThis method is equivalent to
.RelDataType.getFieldList().size()
getFieldCount in interface RelDataTypepublic StructKind getStructKind()
RelDataTypeStructKind.NONE if this is not a structured type.getStructKind in interface RelDataTypepublic @Nullable RelDataType getComponentType()
RelDataTypegetComponentType in interface RelDataTypepublic @Nullable RelDataType getKeyType()
RelDataTypegetKeyType in interface RelDataTypepublic @Nullable RelDataType getValueType()
RelDataTypegetValueType in interface RelDataTypepublic boolean isStruct()
RelDataTypeisStruct in interface RelDataTypepublic String getFullTypeString()
RelDataTypegetFullTypeString in interface RelDataTypepublic boolean isNullable()
RelDataTypeisNullable in interface RelDataTypepublic @Nullable Charset getCharset()
RelDataTypegetCharset in interface RelDataTypepublic @Nullable SqlCollation getCollation()
RelDataTypegetCollation in interface RelDataTypepublic @Nullable SqlIntervalQualifier getIntervalQualifier()
RelDataTypegetIntervalQualifier in interface RelDataTypepublic int getPrecision()
RelDataTypeReturns RelDataType.PRECISION_NOT_SPECIFIED (-1) if precision is not
applicable for this type.
getPrecision in interface RelDataTypepublic int getScale()
RelDataTypeRelDataType.SCALE_NOT_SPECIFIED (-1) if
scale is not valid for this type.getScale in interface RelDataTypepublic SqlTypeName getSqlTypeName()
SqlTypeName of this type.
Sub-classes must override the method to ensure the resulting value is non-nullable.getSqlTypeName in interface RelDataTypepublic @Nullable SqlIdentifier getSqlIdentifier()
RelDataTypeSqlIdentifier associated with this type. For a
predefined type, this is a simple identifier based on
RelDataType.getSqlTypeName(). For a user-defined type, this is a compound
identifier which uniquely names the type.getSqlIdentifier in interface RelDataTypepublic RelDataTypeFamily getFamily()
RelDataTypegetFamily in interface RelDataTypeprotected abstract void generateTypeString(StringBuilder sb, boolean withDetail)
sb - StringBuilder into which to generate the stringwithDetail - when true, all detail information needed to compute a
unique digest (and return from getFullTypeString) should
be included;protected void computeDigest(@UnknownInitialization RelDataTypeImpl this)
public String toString()
RelDataTypetoString in interface RelDataTypetoString in class Objectpublic RelDataTypePrecedenceList getPrecedenceList()
RelDataTypegetPrecedenceList in interface RelDataTypepublic RelDataTypeComparability getComparability()
RelDataTypegetComparability in interface RelDataTypepublic static RelProtoDataType proto(RelDataType protoType)
RelProtoDataType
that copies a given type using the given type factory.public static RelProtoDataType proto(SqlTypeName typeName, boolean nullable)
RelProtoDataType
that will create a type typeName.
For example, proto(SqlTypeName.DATE), false
will create DATE NOT NULL.
typeName - Type namenullable - Whether nullablepublic static RelProtoDataType proto(SqlTypeName typeName, int precision, boolean nullable)
RelProtoDataType
that will create a type typeName(precision).
For example, proto(SqlTypeName.VARCHAR, 100, false)
will create VARCHAR(100) NOT NULL.
typeName - Type nameprecision - Precisionnullable - Whether nullablepublic static RelProtoDataType proto(SqlTypeName typeName, int precision, int scale, boolean nullable)
RelProtoDataType
that will create a type typeName(precision, scale).
For example, proto(SqlTypeName.DECIMAL, 7, 2, false)
will create DECIMAL(7, 2) NOT NULL.
typeName - Type nameprecision - Precisionscale - Scalenullable - Whether nullablepublic static @Nullable RelDataTypeField extra(RelDataType rowType)
rowType - Row typepublic boolean isDynamicStruct()
RelDataTypeisDynamicStruct in interface RelDataTypeCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.