Package org.apache.drill.common.types
Class Types
java.lang.Object
org.apache.drill.common.types.Types
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final TypeProtos.MajorTypestatic final intstatic final TypeProtos.MajorTypestatic final TypeProtos.MajorTypestatic final TypeProtos.MajorTypestatic final TypeProtos.MajorTypestatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareDecimalTypes(TypeProtos.MinorType... types) Returns true if all specified types are decimal data types.static TypeProtos.MajorType.BuildercalculateTypePrecisionAndScale(TypeProtos.MajorType leftType, TypeProtos.MajorType rightType, TypeProtos.MajorType.Builder typeBuilder) Sets max precision from both types if these types are string scalar types.static Stringstatic StringExtend decimal type with precision and scale.static intstatic intgetJdbcTypeCode(String sqlTypeName) Gets JDBC type code for given SQL data type name.static TypeProtos.MajorTypegetMajorTypeFromName(String typeName) static TypeProtos.MajorTypegetMajorTypeFromName(String typeName, TypeProtos.DataMode mode) static TypeProtos.MinorTypegetMinorTypeFromName(String typeName) static Stringstatic intgetPrecision(TypeProtos.MajorType majorType) Get theprecisionof given type.static intgetScale(TypeProtos.MajorType majorType) Get thescaleof given type.static Stringstatic StringGets SQL data type name for given Drill RPC-/protobuf-level data type.static booleanstatic booleanstatic booleanstatic booleanReturns true if specified type is decimal data type.static booleanisDecimalType(TypeProtos.MinorType minorType) Returns true if specified type is decimal data type.static booleanisEquivalent(TypeProtos.MajorType type1, TypeProtos.MajorType type2) Requires full type equality, including fields such as precision and scale.static booleanstatic booleanstatic booleanstatic booleanstatic booleanReports whether given RPC-level type is a signed type (per semantics ofResultSetMetaData.isSigned(int)).static booleanstatic booleanstatic booleanstatic booleanstatic booleanisSameType(TypeProtos.MajorType type1, TypeProtos.MajorType type2) Check if two "core" types are the same, ignoring subtypes and children.static booleanisSameTypeAndMode(TypeProtos.MajorType first, TypeProtos.MajorType second) Check if two "core" types have the same minor type and data mode, ignoring subtypes and children.static booleanChecks if given major type is string scalar type.static booleanChecks if the given type column can be used in ORDER BY clause.static booleanisUnion(TypeProtos.MajorType toType) static booleanstatic booleanstatic intstatic TypeProtos.MajorTypeoptional(TypeProtos.MinorType type) static TypeProtos.MajorTypeoverrideMode(TypeProtos.MajorType originalMajorType, TypeProtos.DataMode overrideMode) static TypeProtos.MajorTyperepeated(TypeProtos.MinorType type) static TypeProtos.MajorTyperequired(TypeProtos.MinorType type) static booleansoftEquals(TypeProtos.MajorType a, TypeProtos.MajorType b, boolean allowNullSwap) static StringtoString(TypeProtos.MajorType type) static StringtypeKey(TypeProtos.MinorType type) The union vector is a map of types.static booleanstatic TypeProtos.MajorTypewithMode(TypeProtos.MinorType type, TypeProtos.DataMode mode) static TypeProtos.MajorTypewithPrecision(TypeProtos.MinorType type, TypeProtos.DataMode mode, int precision) Builds major type using given minor type, data mode and precision.static TypeProtos.MajorTypewithPrecisionAndScale(TypeProtos.MinorType type, TypeProtos.DataMode mode, int precision, int scale)
-
Field Details
-
MAX_VARCHAR_LENGTH
public static final int MAX_VARCHAR_LENGTH- See Also:
-
DEFAULT_TIMESTAMP_PRECISION
public static final int DEFAULT_TIMESTAMP_PRECISION- See Also:
-
UNDEFINED
public static final int UNDEFINED- See Also:
-
NULL
-
LATE_BIND_TYPE
-
REQUIRED_BIT
-
OPTIONAL_BIT
-
OPTIONAL_INT
-
-
Constructor Details
-
Types
public Types()
-
-
Method Details
-
isUnion
-
isComplex
-
isRepeated
-
isNumericType
-
isNumericType
-
isDateTimeType
-
isDateTimeType
-
isIntervalType
-
isIntervalType
-
areDecimalTypes
Returns true if all specified types are decimal data types.- Parameters:
types- types to check- Returns:
- true if all specified types are decimal data type.
-
isDecimalType
Returns true if specified type is decimal data type.- Parameters:
type- type to check- Returns:
- true if specified type is decimal data type.
-
isDecimalType
Returns true if specified type is decimal data type.- Parameters:
minorType- type to check- Returns:
- true if specified type is decimal data type.
-
getSqlTypeName
Gets SQL data type name for given Drill RPC-/protobuf-level data type.- Returns:
- canonical keyword sequence for SQL data type (leading keywords in
corresponding
<data type>; whatINFORMATION_SCHEMA.COLUMNS.TYPE_NAMEwould list)
-
getBaseSqlTypeName
-
getExtendedSqlTypeName
Extend decimal type with precision and scale.- Parameters:
type- major type- Returns:
- type name augmented with precision and scale, if type is a decimal
-
getSqlModeName
-
getJdbcTypeCode
Gets JDBC type code for given SQL data type name. -
isJdbcSignedType
Reports whether given RPC-level type is a signed type (per semantics ofResultSetMetaData.isSigned(int)). -
getJdbcDisplaySize
-
usesHolderForGet
-
isFixedWidthType
-
isFixedWidthType
-
isVarWidthType
-
isScalarStringType
Checks if given major type is string scalar type.- Parameters:
type- major type- Returns:
- true if given major type is scalar string, false otherwise
-
softEquals
public static boolean softEquals(TypeProtos.MajorType a, TypeProtos.MajorType b, boolean allowNullSwap) -
isUntypedNull
-
withMode
-
withPrecision
public static TypeProtos.MajorType withPrecision(TypeProtos.MinorType type, TypeProtos.DataMode mode, int precision) Builds major type using given minor type, data mode and precision.- Parameters:
type- minor typemode- data modeprecision- precision value- Returns:
- major type
-
withPrecisionAndScale
public static TypeProtos.MajorType withPrecisionAndScale(TypeProtos.MinorType type, TypeProtos.DataMode mode, int precision, int scale) -
required
-
repeated
-
optional
-
overrideMode
public static TypeProtos.MajorType overrideMode(TypeProtos.MajorType originalMajorType, TypeProtos.DataMode overrideMode) -
getMajorTypeFromName
-
getMinorTypeFromName
-
getMajorTypeFromName
-
getNameOfMinorType
-
toString
-
getPrecision
Get theprecisionof given type.- Parameters:
majorType- major type- Returns:
- precision value
-
getScale
Get thescaleof given type.- Parameters:
majorType- major type- Returns:
- scale value
-
isSortable
Checks if the given type column can be used in ORDER BY clause.- Parameters:
type- minor type- Returns:
- true if type can be used in ORDER BY clause
-
calculateTypePrecisionAndScale
public static TypeProtos.MajorType.Builder calculateTypePrecisionAndScale(TypeProtos.MajorType leftType, TypeProtos.MajorType rightType, TypeProtos.MajorType.Builder typeBuilder) Sets max precision from both types if these types are string scalar types. Sets max precision and scale from both types if these types are decimal types. Both types should be of the same minor type.- Parameters:
leftType- type from left siderightType- type from right sidetypeBuilder- type builder- Returns:
- type builder
-
isSameType
Check if two "core" types are the same, ignoring subtypes and children. Primarily for non-complex types.- Parameters:
type1- first typetype2- second type- Returns:
- true if the two types have the same minor type, mode, precision and scale
-
isSameTypeAndMode
Check if two "core" types have the same minor type and data mode, ignoring subtypes and children. Primarily for non-complex types.- Parameters:
first- first type to checksecond- second type to check- Returns:
trueif the two types have the same minor type and mode,falseotherwise
-
isEquivalent
Requires full type equality, including fields such as precision and scale. But, unset fields are equivalent to 0. Can't use the protobuf-provided isEquals() which treats set and unset fields as different. -
typeKey
The union vector is a map of types. The following method provides the standard name to use in the type map. It replaces the many ad-hoc appearances of this code in each reference to the map.- Parameters:
type- Drill data type- Returns:
- string key to use for this type in a union vector type map
-
maxPrecision
-
isNullable
-