Package org.apache.calcite.rel.type
Class DynamicRecordTypeImpl
- java.lang.Object
-
- org.apache.calcite.rel.type.RelDataTypeImpl
-
- org.apache.calcite.rel.type.DynamicRecordType
-
- org.apache.calcite.rel.type.DynamicRecordTypeImpl
-
- All Implemented Interfaces:
RelDataType
,RelDataTypeFamily
public class DynamicRecordTypeImpl extends DynamicRecordType
Implementation ofRelDataType
for a dynamic table.It's used during SQL validation, where the field list is mutable for the getField() call. After SQL validation, a normal
RelDataTypeImpl
with an immutable field list takes the place of the DynamicRecordTypeImpl instance.
-
-
Field Summary
Fields Modifier and Type Field Description private RelDataTypeHolder
holder
-
Fields inherited from class org.apache.calcite.rel.type.DynamicRecordType
DYNAMIC_STAR_PREFIX
-
Fields inherited from class org.apache.calcite.rel.type.RelDataTypeImpl
digest, fieldList
-
Fields inherited from interface org.apache.calcite.rel.type.RelDataType
PRECISION_NOT_SPECIFIED, SCALE_NOT_SPECIFIED
-
-
Constructor Summary
Constructors Constructor Description DynamicRecordTypeImpl(RelDataTypeFactory typeFactory)
Creates a DynamicRecordTypeImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
generateTypeString(java.lang.StringBuilder sb, boolean withDetail)
Generates a string representation of this type.RelDataTypeFamily
getFamily()
Gets a canonical object representing the family of this type.RelDataTypeField
getField(java.lang.String fieldName, boolean caseSensitive, boolean elideRecord)
Looks up a field by name.int
getFieldCount()
Returns the number of fields in a struct type.java.util.List<RelDataTypeField>
getFieldList()
Gets the fields in a struct type.java.util.List<java.lang.String>
getFieldNames()
Returns the names of the fields in a struct type.RelDataTypePrecedenceList
getPrecedenceList()
SqlTypeName
getSqlTypeName()
Gets theSqlTypeName
of this type.boolean
isStruct()
Queries whether this is a structured type.-
Methods inherited from class org.apache.calcite.rel.type.DynamicRecordType
isDynamicStarColName, isDynamicStruct
-
Methods inherited from class org.apache.calcite.rel.type.RelDataTypeImpl
computeDigest, equals, extra, getCharset, getCollation, getComparability, getComponentType, getFullTypeString, getIntervalQualifier, getKeyType, getPrecision, getScale, getSqlIdentifier, getStructKind, getValueType, hashCode, isNullable, proto, proto, proto, proto, toString
-
-
-
-
Field Detail
-
holder
private final RelDataTypeHolder holder
-
-
Constructor Detail
-
DynamicRecordTypeImpl
public DynamicRecordTypeImpl(RelDataTypeFactory typeFactory)
Creates a DynamicRecordTypeImpl.
-
-
Method Detail
-
getFieldList
public java.util.List<RelDataTypeField> getFieldList()
Description copied from interface:RelDataType
Gets the fields in a struct type. The field count is equal to the size of the returned list.- Specified by:
getFieldList
in interfaceRelDataType
- Overrides:
getFieldList
in classRelDataTypeImpl
- Returns:
- read-only list of fields
-
getFieldCount
public int getFieldCount()
Description copied from interface:RelDataType
Returns the number of fields in a struct type.This method is equivalent to
.RelDataType.getFieldList()
.size()- Specified by:
getFieldCount
in interfaceRelDataType
- Overrides:
getFieldCount
in classRelDataTypeImpl
-
getField
public RelDataTypeField getField(java.lang.String fieldName, boolean caseSensitive, boolean elideRecord)
Description copied from interface:RelDataType
Looks up a field by name.NOTE: Be careful choosing the value of
caseSensitive
:- If the field name was supplied by an end-user (e.g. as a column alias in SQL), use your session's case-sensitivity setting.
- Only hard-code
true
if you are sure that the field name is internally generated. - Hard-coding
false
is almost certainly wrong.
- Specified by:
getField
in interfaceRelDataType
- Overrides:
getField
in classRelDataTypeImpl
- Parameters:
fieldName
- Name of field to findcaseSensitive
- Whether match is case-sensitiveelideRecord
- Whether to find fields nested within records- Returns:
- named field, or null if not found
-
getFieldNames
public java.util.List<java.lang.String> getFieldNames()
Description copied from interface:RelDataType
Returns the names of the fields in a struct type. The field count is equal to the size of the returned list.- Specified by:
getFieldNames
in interfaceRelDataType
- Overrides:
getFieldNames
in classRelDataTypeImpl
- Returns:
- read-only list of field names
-
getSqlTypeName
public SqlTypeName getSqlTypeName()
Description copied from interface:RelDataType
Gets theSqlTypeName
of this type.- Specified by:
getSqlTypeName
in interfaceRelDataType
- Overrides:
getSqlTypeName
in classRelDataTypeImpl
- Returns:
- SqlTypeName, or null if this is not an SQL predefined type
-
getPrecedenceList
public RelDataTypePrecedenceList getPrecedenceList()
- Specified by:
getPrecedenceList
in interfaceRelDataType
- Overrides:
getPrecedenceList
in classRelDataTypeImpl
- Returns:
- precedence list for this type
-
generateTypeString
protected void generateTypeString(java.lang.StringBuilder sb, boolean withDetail)
Description copied from class:RelDataTypeImpl
Generates a string representation of this type.- Specified by:
generateTypeString
in classRelDataTypeImpl
- Parameters:
sb
- StringBuffer into which to generate the stringwithDetail
- when true, all detail information needed to compute a unique digest (and return from getFullTypeString) should be included;
-
isStruct
public boolean isStruct()
Description copied from interface:RelDataType
Queries whether this is a structured type.- Specified by:
isStruct
in interfaceRelDataType
- Overrides:
isStruct
in classRelDataTypeImpl
- Returns:
- whether this type has fields; examples include rows and user-defined structured types in SQL, and classes in Java
-
getFamily
public RelDataTypeFamily getFamily()
Description copied from interface:RelDataType
Gets a canonical object representing the family of this type. Two values can be compared if and only if their types are in the same family.- Specified by:
getFamily
in interfaceRelDataType
- Overrides:
getFamily
in classRelDataTypeImpl
- Returns:
- canonical object representing type family
-
-