Class SqlTypeUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RelDataTypeaddCharsetAndCollation(RelDataType type, RelDataTypeFactory typeFactory) Adds collation and charset to a character type, returns other types unchanged.static booleanallNullable(List<RelDataType> types) Returns whether all of array of types are nullable.static booleanDetermines whether two types both have different character sets.static booleanareSameFamily(Iterable<RelDataType> types) Returns whether all types in a collection have the same family, as determined byisSameFamily(RelDataType, RelDataType).static booleancanAssignFrom(RelDataType toType, RelDataType fromType) Tests whether a value can be assigned to a site.static booleancanBeRepresentedExactly(@Nullable BigDecimal value, RelDataType toType) Returns whether the decimal value can be represented without information loss using the specified type.static booleancanCastFrom(RelDataType toType, RelDataType fromType, boolean coerce) Compares two types and returns whetherfromTypecan be cast totoType, using either coercion or assignment.static booleancanCastFrom(RelDataType toType, RelDataType fromType, SqlTypeMappingRule typeMappingRule) Compares two types and returns whetherfromTypecan be cast totoType.static intcomparePrecision(int p0, int p1) Returns whether a precision is greater or equal than another, treatingRelDataType.PRECISION_NOT_SPECIFIEDas infinity.static booleancontainsNullable(List<RelDataType> types) Returns whether one or more of an array of types is nullable.static booleancontainsNullable(RelDataType type) Determines whether a type or any of its fields (if a structured type) are nullable.static SqlDataTypeSpecconvertTypeToSpec(RelDataType type) Converts an instance of RelDataType to an instance of SqlDataTypeSpec.static SqlDataTypeSpecconvertTypeToSpec(RelDataType type, @Nullable String charSetName, int maxPrecision, int maxScale) Converts an instance of RelDataType to an instance of SqlDataTypeSpec.static RelDataTypecreateArrayType(RelDataTypeFactory typeFactory, RelDataType type, boolean nullable) static RelDataTypecreateEmptyStructType(RelDataTypeFactory typeFactory) Records a struct type with no fields.static RelDataTypecreateMapType(RelDataTypeFactory typeFactory, RelDataType keyType, RelDataType valueType, boolean nullable) static RelDataTypecreateMapTypeFromRecord(RelDataTypeFactory typeFactory, RelDataType type) Creates a MAP type from a record type.static RelDataTypecreateMultisetType(RelDataTypeFactory typeFactory, RelDataType type, boolean nullable) static RelDataTypecreateRecordTypeFromMap(RelDataTypeFactory typeFactory, RelDataType type) Creates a ROW type from a map type.static List<RelDataType>deriveAndCollectTypes(SqlValidator validator, SqlValidatorScope scope, List<? extends SqlNode> operands) Iterates over all operands, derives their types, and collects them into a list.static RelDataTypederiveCollectionQueryComponentType(SqlTypeName collectionType, RelDataType origin) Derives component type for ARRAY, MULTISET, MAP when input is sub-query.static RelDataTypederiveType(SqlCallBinding binding) Derives type of the call via its binding.static List<RelDataType>deriveType(SqlCallBinding binding, List<? extends SqlNode> nodes) Derives types for the list of nodes.static RelDataTypederiveType(SqlCallBinding binding, SqlNode node) Derives type of the given call under given binding.static booleanequalAsCollectionSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2) Returns whether two collection types are equal, ignoring nullability.static booleanequalAsMapSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2) Returns whether two map types are equal, ignoring nullability.static booleanequalAsStructSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2, @Nullable SqlNameMatcher nameMatcher) Returns whether two struct types are equal, ignoring nullability.static booleanequalSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2) Returns whether two types are equal, ignoring nullability.static booleanequalSansNullability(RelDataType type1, RelDataType type2) This is a poorman'sequalSansNullability(RelDataTypeFactory, RelDataType, RelDataType).static RelDataTypeextractLastNFields(RelDataTypeFactory typeFactory, RelDataType type, int numToKeep) Keeps only the last N fields and returns the new struct type.protected static RelDataTypeFamilyfamily(RelDataType type) static intfindField(RelDataType type, String fieldName) Returns the ordinal of a given field in a record type, or -1 if the field is not found.static RelDataTypeflattenRecordType(RelDataTypeFactory typeFactory, RelDataType recordType, int @Nullable [] flatteningMap) Flattens a record type by recursively expanding any fields which are themselves record types.static RelDataTypefromMeasure(RelDataTypeFactory typeFactory, RelDataType type) Strips MEASURE wrappers from a type.static intgetMaxByteSize(RelDataType type) Computes the maximum number of bytes required to represent a value of a type having user-defined precision.static RelDataTypeReturns a DECIMAL type with the maximum precision for the current type system.static longgetMaxValue(RelDataType type) Returns the maximum unscaled value of a numeric type.static longgetMinValue(RelDataType type) Returns the minimum unscaled value of a numeric type.static @Nullable StringgetNumericJavaClassName(@Nullable RelDataType type) Deprecated.static @Nullable StringgetPrimitiveWrapperJavaClassName(@Nullable RelDataType type) Deprecated.static booleanhasCharacter(RelDataType type) Returns whether a type is a CHARACTER or contains a CHARACTER type.static booleanhasCharactor(RelDataType type) Deprecated.static booleanhasScale(RelDataType type) Returns whether a type's scale is set.static booleaninBooleanFamily(RelDataType type) Returns whether a type is in SqlTypeFamily.Boolean.static booleaninCharFamily(RelDataType type) Returns whether a type is in SqlTypeFamily.Character.static booleaninCharFamily(SqlTypeName typeName) Returns whether a type name is in SqlTypeFamily.Character.static booleanReturns whether a type family is either character or binary.static booleaninSameFamily(RelDataType t1, RelDataType t2) Returns whether two types are in same type family.static booleaninSameFamilyOrNull(RelDataType t1, RelDataType t2) Returns whether two types are in same type family, or one or the other is of typeSqlTypeName.NULL.static booleanReturns whether a type is numeric with approximate precision.static booleanisArray(RelDataType type) Returns whether a type is ARRAY.static booleanisAtomic(RelDataType type) Returns whether a type is atomic (datetime, numeric, string or BOOLEAN).static booleanisBinary(RelDataType type) Returns whether a type is BINARY.static booleanisBoolean(RelDataType type) Returns whether a type is BOOLEAN.static booleanReturns whether a type is variable width with bounded precision.static booleanisCharacter(RelDataType type) Returns whether a type is CHARACTER.static booleanisCharTypeComparable(List<RelDataType> argTypes) Checks whether two types or more are char comparable.static booleanisCharTypeComparable(SqlCallBinding binding, List<SqlNode> operands, boolean throwOnFailure) Returns whether the operands to a call are char type-comparable.static booleanisCollection(RelDataType type) Returns whether a type is ARRAY or MULTISET.static booleanisComparable(RelDataType type1, RelDataType type2) Returns whether two types are comparable.static booleanisDate(RelDataType type) Returns whether a type is DATE.static booleanisDatetime(RelDataType type) Returns whether a type is DATE, TIME, or TIMESTAMP.static booleanisDecimal(RelDataType type) Returns whether a type is DECIMAL.static booleanisExactNumeric(RelDataType type) Returns whether a type is numeric with exact precision.static booleanisFlat(RelDataType type) Returns whether a type is flat.static booleanisInterval(RelDataType type) Returns whether a type is some kind of INTERVAL.static booleanisIntType(RelDataType type) Returns whether a type is one of the integer types.static booleanisJavaPrimitive(RelDataType type) Deprecated.static booleanisLob(RelDataType type) Returns whether a type is a LOB of some kind.static booleanisMap(RelDataType type) Returns whether a type is MAP.static booleanstatic booleanisMultiset(RelDataType type) Returns whether a type is MULTISET.static booleanisNull(RelDataType type) Returns whether a type is the NULL type.static booleanisNumeric(RelDataType type) Returns whether a type is numeric.static booleanisOfSameTypeName(Collection<SqlTypeName> typeNames, RelDataType type) Returns true if any element intypeNamesmatches type.getSqlTypeName().static booleanisOfSameTypeName(SqlTypeName typeName, RelDataType type) Returns typeName.equals(type.getSqlTypeName()).static booleanisRow(RelDataType type) Returns whether a type is ROW.static booleanisString(RelDataType type) Returns whether a type is STRING.static booleanisTimestamp(RelDataType type) Returns whether a type is TIMESTAMP.static booleanisUnicode(RelDataType type) Checks whether a type represents Unicode character data.static booleanisValidDecimalValue(@Nullable BigDecimal value, RelDataType toType) Returns whether the decimal value is valid for the type.static RelDataTypekeepSourceTypeAndTargetNullability(RelDataType sourceRelDataType, RelDataType targetRelDataType, RelDataTypeFactory typeFactory) Creates a RelDataType having the same type of the sourceRelDataType, and the same nullability as the targetRelDataType.static @Nullable RelDataTypeleastRestrictiveForComparison(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2) Returns the least restrictive type T, such that a value of type T can be compared with values of typetype1andtype2using=.static RelDataTypemakeNullableIfOperandsAre(RelDataTypeFactory typeFactory, List<RelDataType> argTypes, RelDataType type) Recreates a given RelDataType with nullability iff any of the param argTypes are nullable.static RelDataTypemakeNullableIfOperandsAre(SqlValidator validator, SqlValidatorScope scope, SqlCall call, RelDataType type) Recreates a given RelDataType with nullability iff any of the operands of a call are nullable.static intmaxPrecision(int p0, int p1) Returns the larger of two precisions, treatingRelDataType.PRECISION_NOT_SPECIFIEDas infinity.static longmaxValue(RelDataType type) Returns the maximum value of an integral type, as a long value.static booleanneedsNullIndicator(RelDataType recordType) static List<RelDataType>projectTypes(RelDataType rowType, List<? extends Number> requiredFields) Selects data types of the specified fields from an input row type.static RelDataTypepromoteToRowType(RelDataTypeFactory typeFactory, RelDataType type, @Nullable String fieldName) Promotes a type to a row type (does nothing if it already is one).static booleansameNamedType(RelDataType t1, RelDataType t2) Tests whether two types have the same name and structure, possibly with differing modifiers.
-
Constructor Details
-
SqlTypeUtil
public SqlTypeUtil()
-
-
Method Details
-
isCharTypeComparable
Checks whether two types or more are char comparable.- Returns:
- Returns true if all operands are of char type and if they are comparable, i.e. of the same charset and collation of same charset
-
isCharTypeComparable
public static boolean isCharTypeComparable(SqlCallBinding binding, List<SqlNode> operands, boolean throwOnFailure) Returns whether the operands to a call are char type-comparable.- Parameters:
binding- Binding of call to operandsoperands- Operands to check for compatibility; usually the operands of the bound call, but not alwaysthrowOnFailure- Whether to throw an exception on failure- Returns:
- whether operands are valid
-
deriveCollectionQueryComponentType
public static RelDataType deriveCollectionQueryComponentType(SqlTypeName collectionType, RelDataType origin) Derives component type for ARRAY, MULTISET, MAP when input is sub-query.- Parameters:
origin- original component type- Returns:
- component type
-
deriveAndCollectTypes
public static List<RelDataType> deriveAndCollectTypes(SqlValidator validator, SqlValidatorScope scope, List<? extends SqlNode> operands) Iterates over all operands, derives their types, and collects them into a list. -
deriveType
@API(since="1.26", status=EXPERIMENTAL) public static RelDataType deriveType(SqlCallBinding binding) Derives type of the call via its binding.- Parameters:
binding- binding to derive the type from- Returns:
- datatype of the call
-
deriveType
@API(since="1.26", status=EXPERIMENTAL) public static RelDataType deriveType(SqlCallBinding binding, SqlNode node) Derives type of the given call under given binding.- Parameters:
binding- binding to derive the type fromnode- node type to derive- Returns:
- datatype of the given node
-
deriveType
@API(since="1.26", status=EXPERIMENTAL) public static List<RelDataType> deriveType(SqlCallBinding binding, List<? extends SqlNode> nodes) Derives types for the list of nodes.- Parameters:
binding- binding to derive the type fromnodes- the list of nodes to derive types from- Returns:
- the list of types of the given nodes
-
promoteToRowType
public static RelDataType promoteToRowType(RelDataTypeFactory typeFactory, RelDataType type, @Nullable String fieldName) Promotes a type to a row type (does nothing if it already is one).- Parameters:
type- type to be promotedfieldName- name to give field in row type; null for default of "ROW_VALUE"- Returns:
- row type
-
makeNullableIfOperandsAre
public static RelDataType makeNullableIfOperandsAre(SqlValidator validator, SqlValidatorScope scope, SqlCall call, RelDataType type) Recreates a given RelDataType with nullability iff any of the operands of a call are nullable. -
makeNullableIfOperandsAre
public static RelDataType makeNullableIfOperandsAre(RelDataTypeFactory typeFactory, List<RelDataType> argTypes, RelDataType type) Recreates a given RelDataType with nullability iff any of the param argTypes are nullable. -
allNullable
Returns whether all of array of types are nullable. -
containsNullable
Returns whether one or more of an array of types is nullable. -
containsNullable
Determines whether a type or any of its fields (if a structured type) are nullable. -
keepSourceTypeAndTargetNullability
public static RelDataType keepSourceTypeAndTargetNullability(RelDataType sourceRelDataType, RelDataType targetRelDataType, RelDataTypeFactory typeFactory) Creates a RelDataType having the same type of the sourceRelDataType, and the same nullability as the targetRelDataType. -
isOfSameTypeName
Returns typeName.equals(type.getSqlTypeName()). If typeName.equals(SqlTypeName.Any) true is always returned. -
isOfSameTypeName
Returns true if any element intypeNamesmatches type.getSqlTypeName(). -
isDatetime
Returns whether a type is DATE, TIME, or TIMESTAMP. -
isDate
Returns whether a type is DATE. -
isTimestamp
Returns whether a type is TIMESTAMP. -
isInterval
@EnsuresNonNullIf(expression="#1.getIntervalQualifier()", result=true) public static boolean isInterval(RelDataType type) Returns whether a type is some kind of INTERVAL. -
inCharFamily
@EnsuresNonNullIf(expression="#1.getCharset()",result=true) @EnsuresNonNullIf(expression="#1.getCollation()",result=true) public static boolean inCharFamily(RelDataType type) Returns whether a type is in SqlTypeFamily.Character. -
inCharFamily
Returns whether a type name is in SqlTypeFamily.Character. -
inBooleanFamily
Returns whether a type is in SqlTypeFamily.Boolean. -
inSameFamily
Returns whether two types are in same type family. -
inSameFamilyOrNull
Returns whether two types are in same type family, or one or the other is of typeSqlTypeName.NULL. -
inCharOrBinaryFamilies
Returns whether a type family is either character or binary. -
isLob
Returns whether a type is a LOB of some kind. -
isBoundedVariableWidth
Returns whether a type is variable width with bounded precision. -
isIntType
Returns whether a type is one of the integer types. -
isDecimal
Returns whether a type is DECIMAL. -
isExactNumeric
Returns whether a type is numeric with exact precision. -
hasScale
Returns whether a type's scale is set. -
maxValue
Returns the maximum value of an integral type, as a long value. -
isApproximateNumeric
Returns whether a type is numeric with approximate precision. -
isNumeric
Returns whether a type is numeric. -
isNull
Returns whether a type is the NULL type. -
sameNamedType
Tests whether two types have the same name and structure, possibly with differing modifiers. For example, VARCHAR(1) and VARCHAR(10) are considered the same, while VARCHAR(1) and CHAR(1) are considered different. Likewise, VARCHAR(1) MULTISET and VARCHAR(10) MULTISET are considered the same.- Returns:
- true if types have same name and structure
-
getMaxByteSize
Computes the maximum number of bytes required to represent a value of a type having user-defined precision. This computation assumes no overhead such as length indicators and NUL-terminators. Complex types for which multiple representations are possible (e.g. DECIMAL or TIMESTAMP) return 0.- Parameters:
type- type for which to compute storage- Returns:
- maximum bytes, or 0 for a fixed-width type or type with unknown maximum
-
getMinValue
Returns the minimum unscaled value of a numeric type.- Parameters:
type- a numeric type
-
getMaxValue
Returns the maximum unscaled value of a numeric type.- Parameters:
type- a numeric type
-
isJavaPrimitive
Deprecated.Returns whether a type has a representation as a Java primitive (ignoring nullability). -
getPrimitiveWrapperJavaClassName
@Deprecated public static @Nullable String getPrimitiveWrapperJavaClassName(@Nullable RelDataType type) Deprecated.Returns the class name of the wrapper for the primitive data type. -
getNumericJavaClassName
Deprecated.Returns the class name of a numeric data type. -
isMeasure
-
canAssignFrom
Tests whether a value can be assigned to a site.- Parameters:
toType- type of the target sitefromType- type of the source value- Returns:
- true iff assignable
-
areCharacterSetsMismatched
Determines whether two types both have different character sets. If one or the other type has no character set (e.g. in cast from INT to VARCHAR), that is not a mismatch.- Parameters:
t1- first typet2- second type- Returns:
- true iff mismatched
-
canCastFrom
Compares two types and returns whetherfromTypecan be cast totoType, using either coercion or assignment.REVIEW jvs 17-Dec-2004: the coerce param below shouldn't really be necessary. We're using it as a hack because
SqlTypeFactoryImpl.leastRestrictive(java.util.List<org.apache.calcite.rel.type.RelDataType>, org.apache.calcite.sql.type.SqlTypeMappingRule)isn't complete enough yet. Once it is, this param (and the non-coerce rules ofSqlTypeAssignmentRule) should go away.- Parameters:
toType- target of assignmentfromType- source of assignmentcoerce- if true, the SQL rules for CAST are used; if false, the rules are similar to Java; e.g. you can't assign short x = (int) y, and you can't assign int x = (String) z.- Returns:
- whether cast is legal
-
canCastFrom
public static boolean canCastFrom(RelDataType toType, RelDataType fromType, SqlTypeMappingRule typeMappingRule) Compares two types and returns whetherfromTypecan be cast totoType.A type mapping rule (i.e.
SqlTypeCoercionRuleorSqlTypeAssignmentRule) controls what types are allowed to be cast from/to.- Parameters:
toType- target of assignmentfromType- source of assignmenttypeMappingRule- SqlTypeMappingRule- Returns:
- whether cast is legal
-
flattenRecordType
public static RelDataType flattenRecordType(RelDataTypeFactory typeFactory, RelDataType recordType, int @Nullable [] flatteningMap) Flattens a record type by recursively expanding any fields which are themselves record types. For each record type, a representative null value field is also prepended (with state NULL for a null value and FALSE for non-null), and all component types are asserted to be nullable, since SQL doesn't allow NOT NULL to be specified on attributes.- Parameters:
typeFactory- factory which should produced flattened typerecordType- type with possible nestingflatteningMap- if non-null, receives map from unflattened ordinal to flattened ordinal (must have length at least recordType.getFieldList().size())- Returns:
- flattened equivalent
-
needsNullIndicator
-
convertTypeToSpec
public static SqlDataTypeSpec convertTypeToSpec(RelDataType type, @Nullable String charSetName, int maxPrecision, int maxScale) Converts an instance of RelDataType to an instance of SqlDataTypeSpec.- Parameters:
type- type descriptorcharSetName- charSet namemaxPrecision- The max allowed precision.maxScale- max allowed scale- Returns:
- corresponding parse representation
-
convertTypeToSpec
Converts an instance of RelDataType to an instance of SqlDataTypeSpec.- Parameters:
type- type descriptor- Returns:
- corresponding parse representation
-
createMultisetType
public static RelDataType createMultisetType(RelDataTypeFactory typeFactory, RelDataType type, boolean nullable) -
createArrayType
public static RelDataType createArrayType(RelDataTypeFactory typeFactory, RelDataType type, boolean nullable) -
createMapType
public static RelDataType createMapType(RelDataTypeFactory typeFactory, RelDataType keyType, RelDataType valueType, boolean nullable) -
createMapTypeFromRecord
Creates a MAP type from a record type. The record type must have exactly two fields. -
createRecordTypeFromMap
Creates a ROW type from a map type. The record type will have two fields. -
addCharsetAndCollation
Adds collation and charset to a character type, returns other types unchanged.- Parameters:
type- TypetypeFactory- Type factory- Returns:
- Type with added charset and collation, or unchanged type if it is not a char type.
-
equalSansNullability
public static boolean equalSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2) Returns whether two types are equal, ignoring nullability.They need not come from the same factory.
- Parameters:
factory- Type factorytype1- First typetype2- Second type- Returns:
- whether types are equal, ignoring nullability
-
equalSansNullability
This is a poorman'sequalSansNullability(RelDataTypeFactory, RelDataType, RelDataType).We assume that "not null" is represented in the type's digest as a trailing "NOT NULL" (case sensitive).
If you got a type factory,
equalSansNullability(RelDataTypeFactory, RelDataType, RelDataType)is preferred.- Parameters:
type1- First typetype2- Second type- Returns:
- true if the types are equal or the only difference is nullability
-
equalAsCollectionSansNullability
public static boolean equalAsCollectionSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2) Returns whether two collection types are equal, ignoring nullability.They need not come from the same factory.
- Parameters:
factory- Type factorytype1- First typetype2- Second type- Returns:
- Whether types are equal, ignoring nullability
-
equalAsMapSansNullability
public static boolean equalAsMapSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2) Returns whether two map types are equal, ignoring nullability.They need not come from the same factory.
- Parameters:
factory- Type factorytype1- First typetype2- Second type- Returns:
- Whether types are equal, ignoring nullability
-
equalAsStructSansNullability
public static boolean equalAsStructSansNullability(RelDataTypeFactory factory, RelDataType type1, RelDataType type2, @Nullable SqlNameMatcher nameMatcher) Returns whether two struct types are equal, ignoring nullability.They do not need to come from the same factory.
- Parameters:
factory- Type factorytype1- First typetype2- Second typenameMatcher- Name matcher used to compare the field names, if null, the field names are also ignored- Returns:
- Whether types are equal, ignoring nullability
-
findField
Returns the ordinal of a given field in a record type, or -1 if the field is not found.The
fieldNameis always simple, if the field is nested within a record field, returns index of the outer field instead. i.g. for row type (a int, b (b1 bigint, b2 varchar(20) not null)), returns 1 for both simple name "b1" and "b2".- Parameters:
type- Record typefieldName- Name of field- Returns:
- Ordinal of field
-
projectTypes
public static List<RelDataType> projectTypes(RelDataType rowType, List<? extends Number> requiredFields) Selects data types of the specified fields from an input row type. This is useful when identifying data types of a function that is going to operate on inputs that are specified as field ordinals (e.g. aggregate calls).- Parameters:
rowType- input row typerequiredFields- ordinals of the projected fields- Returns:
- list of data types that are requested by requiredFields
-
createEmptyStructType
Records a struct type with no fields.- Parameters:
typeFactory- Type factory- Returns:
- Struct type with no fields
-
isFlat
Returns whether a type is flat. It is not flat if it is a record type that has one or more fields that are themselves record types. -
isComparable
Returns whether two types are comparable. They need to be scalar types of the same family, or struct types whose fields are pairwise comparable. Note that types in the CHARACTER family are comparable with many other types (seecanConvertStringInCompare(org.apache.calcite.rel.type.RelDataTypeFamily)).- Parameters:
type1- First typetype2- Second type- Returns:
- Whether types are comparable
-
leastRestrictiveForComparison
public static @Nullable RelDataType leastRestrictiveForComparison(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2) Returns the least restrictive type T, such that a value of type T can be compared with values of typetype1andtype2using=. -
family
-
areSameFamily
Returns whether all types in a collection have the same family, as determined byisSameFamily(RelDataType, RelDataType).- Parameters:
types- Types to check- Returns:
- true if all types are of the same family
-
isUnicode
Checks whether a type represents Unicode character data.- Parameters:
type- type to test- Returns:
- whether type represents Unicode character data
-
maxPrecision
public static int maxPrecision(int p0, int p1) Returns the larger of two precisions, treatingRelDataType.PRECISION_NOT_SPECIFIEDas infinity. -
comparePrecision
public static int comparePrecision(int p0, int p1) Returns whether a precision is greater or equal than another, treatingRelDataType.PRECISION_NOT_SPECIFIEDas infinity. -
isArray
Returns whether a type is ARRAY. -
isRow
Returns whether a type is ROW. -
isMap
Returns whether a type is MAP. -
isMultiset
Returns whether a type is MULTISET. -
isCollection
Returns whether a type is ARRAY or MULTISET. -
isCharacter
Returns whether a type is CHARACTER. -
hasCharactor
Deprecated.Returns whether a type is a CHARACTER or contains a CHARACTER type. -
hasCharacter
Returns whether a type is a CHARACTER or contains a CHARACTER type. -
isString
Returns whether a type is STRING. -
isBoolean
Returns whether a type is BOOLEAN. -
isBinary
Returns whether a type is BINARY. -
isAtomic
Returns whether a type is atomic (datetime, numeric, string or BOOLEAN). -
getMaxPrecisionScaleDecimal
Returns a DECIMAL type with the maximum precision for the current type system. -
extractLastNFields
public static RelDataType extractLastNFields(RelDataTypeFactory typeFactory, RelDataType type, int numToKeep) Keeps only the last N fields and returns the new struct type. -
canBeRepresentedExactly
Returns whether the decimal value can be represented without information loss using the specified type. For example, 1111.11 - cannot be represented exactly using DECIMAL(3, 1) since it overflows. - cannot be represented exactly using DECIMAL(6, 3) since it overflows. - cannot be represented exactly using DECIMAL(6, 1) since it requires rounding. - can be represented exactly using DECIMAL(6, 2)- Parameters:
value- A decimal valuetoType- A DECIMAL type.- Returns:
- whether the value is valid for the type
-
isValidDecimalValue
Returns whether the decimal value is valid for the type. For example, 1111.11 is not valid for DECIMAL(3, 1) since it overflows.- Parameters:
value- Value of literaltoType- Type of the literal- Returns:
- whether the value is valid for the type
-
fromMeasure
Strips MEASURE wrappers from a type.For example:
- "
INTEGER" remains "INTEGER"; - "
MEASURE<DECIMAL>" becomes "DECIMAL"; - "
(empno INTEGER NOT NULL, rating MEASURE<DECIMAL>)" becomes "(empno INTEGER NOT NULL, rating DECIMAL)".
- "
-
hasCharacter(RelDataType)