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
- Direct Known Subclasses:
DynamicTupleRecordType
Implementation of
RelDataType 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 inherited from class org.apache.calcite.rel.type.DynamicRecordType
DYNAMIC_STAR_PREFIXFields inherited from class org.apache.calcite.rel.type.RelDataTypeImpl
digest, fieldList, NON_NULLABLE_SUFFIXFields inherited from interface org.apache.calcite.rel.type.RelDataType
PRECISION_NOT_SPECIFIED, SCALE_NOT_SPECIFIED -
Constructor Summary
ConstructorsConstructorDescriptionDynamicRecordTypeImpl(RelDataTypeFactory typeFactory) Creates a DynamicRecordTypeImpl. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgenerateTypeString(StringBuilder sb, boolean withDetail) Generates a string representation of this type.Gets a canonical object representing the family of this type.@Nullable RelDataTypeFieldLooks up a field by name.intReturns the number of fields in a struct type.Gets the fields in a struct type.Returns the names of the fields in a struct type.Returns the precedence list for this type.Gets theSqlTypeNameof this type.booleanisStruct()Queries whether this is a structured type.Methods inherited from class org.apache.calcite.rel.type.DynamicRecordType
isDynamicStarColName, isDynamicStructMethods inherited from class org.apache.calcite.rel.type.RelDataTypeImpl
computeDigest, equals, extra, getCharset, getCollation, getComparability, getComponentType, getFieldMap, getFullTypeString, getIntervalQualifier, getKeyType, getPrecision, getScale, getSqlIdentifier, getStructKind, getValueType, hashCode, isNullable, proto, proto, proto, proto, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.rel.type.RelDataType
equalsSansFieldNames, equalsSansFieldNamesAndNullability, getMeasureElementType, isMeasure
-
Constructor Details
-
DynamicRecordTypeImpl
Creates a DynamicRecordTypeImpl.
-
-
Method Details
-
getFieldList
Description copied from interface:RelDataTypeGets the fields in a struct type. The field count is equal to the size of the returned list.- Specified by:
getFieldListin interfaceRelDataType- Overrides:
getFieldListin classRelDataTypeImpl- Returns:
- read-only list of fields
-
getFieldCount
public int getFieldCount()Description copied from interface:RelDataTypeReturns the number of fields in a struct type.This method is equivalent to
.RelDataType.getFieldList().size()- Specified by:
getFieldCountin interfaceRelDataType- Overrides:
getFieldCountin classRelDataTypeImpl
-
getField
public @Nullable RelDataTypeField getField(String fieldName, boolean caseSensitive, boolean elideRecord) Description copied from interface:RelDataTypeLooks 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
trueif you are sure that the field name is internally generated. - Hard-coding
falseis almost certainly wrong.
- Specified by:
getFieldin interfaceRelDataType- Overrides:
getFieldin 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
Description copied from interface:RelDataTypeReturns the names of the fields in a struct type. The field count is equal to the size of the returned list.- Specified by:
getFieldNamesin interfaceRelDataType- Overrides:
getFieldNamesin classRelDataTypeImpl- Returns:
- read-only list of field names
-
getSqlTypeName
Description copied from class:RelDataTypeImplGets theSqlTypeNameof this type. Sub-classes must override the method to ensure the resulting value is non-nullable.- Specified by:
getSqlTypeNamein interfaceRelDataType- Overrides:
getSqlTypeNamein classRelDataTypeImpl- Returns:
- SqlTypeName, never null
-
getPrecedenceList
Description copied from interface:RelDataTypeReturns the precedence list for this type.- Specified by:
getPrecedenceListin interfaceRelDataType- Overrides:
getPrecedenceListin classRelDataTypeImpl
-
generateTypeString
Description copied from class:RelDataTypeImplGenerates a string representation of this type.- Specified by:
generateTypeStringin classRelDataTypeImpl- Parameters:
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;
-
isStruct
public boolean isStruct()Description copied from interface:RelDataTypeQueries whether this is a structured type.- Specified by:
isStructin interfaceRelDataType- Overrides:
isStructin classRelDataTypeImpl- Returns:
- whether this type has fields; examples include rows and user-defined structured types in SQL, and classes in Java
-
getFamily
Description copied from interface:RelDataTypeGets 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:
getFamilyin interfaceRelDataType- Overrides:
getFamilyin classRelDataTypeImpl- Returns:
- canonical object representing type family, never null
-