Package org.apache.drill.common.types
Class Types
java.lang.Object
org.apache.drill.common.types.Types
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final TypeProtos.MajorType
static final int
static final TypeProtos.MajorType
static final TypeProtos.MajorType
static final TypeProtos.MajorType
static final TypeProtos.MajorType
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areDecimalTypes
(TypeProtos.MinorType... types) Returns true if all specified types are decimal data types.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.static String
static String
Extend decimal type with precision and scale.static int
static int
getJdbcTypeCode
(String sqlTypeName) Gets JDBC type code for given SQL data type name.static TypeProtos.MajorType
getMajorTypeFromName
(String typeName) static TypeProtos.MajorType
getMajorTypeFromName
(String typeName, TypeProtos.DataMode mode) static TypeProtos.MinorType
getMinorTypeFromName
(String typeName) static String
static int
getPrecision
(TypeProtos.MajorType majorType) Get theprecision
of given type.static int
getScale
(TypeProtos.MajorType majorType) Get thescale
of given type.static String
static String
Gets SQL data type name for given Drill RPC-/protobuf-level data type.static boolean
static boolean
static boolean
static boolean
Returns true if specified type is decimal data type.static boolean
isDecimalType
(TypeProtos.MinorType minorType) Returns true if specified type is decimal data type.static boolean
isEquivalent
(TypeProtos.MajorType type1, TypeProtos.MajorType type2) Requires full type equality, including fields such as precision and scale.static boolean
static boolean
static boolean
static boolean
static boolean
Reports whether given RPC-level type is a signed type (per semantics ofResultSetMetaData.isSigned(int)
).static boolean
static boolean
static boolean
static boolean
static boolean
isSameType
(TypeProtos.MajorType type1, TypeProtos.MajorType type2) Check if two "core" types are the same, ignoring subtypes and children.static boolean
isSameTypeAndMode
(TypeProtos.MajorType first, TypeProtos.MajorType second) Check if two "core" types have the same minor type and data mode, ignoring subtypes and children.static boolean
Checks if given major type is string scalar type.static boolean
Checks if the given type column can be used in ORDER BY clause.static boolean
isUnion
(TypeProtos.MajorType toType) static boolean
static boolean
static int
static TypeProtos.MajorType
optional
(TypeProtos.MinorType type) static TypeProtos.MajorType
overrideMode
(TypeProtos.MajorType originalMajorType, TypeProtos.DataMode overrideMode) static TypeProtos.MajorType
repeated
(TypeProtos.MinorType type) static TypeProtos.MajorType
required
(TypeProtos.MinorType type) static boolean
softEquals
(TypeProtos.MajorType a, TypeProtos.MajorType b, boolean allowNullSwap) static String
toString
(TypeProtos.MajorType type) static String
typeKey
(TypeProtos.MinorType type) The union vector is a map of types.static boolean
static TypeProtos.MajorType
withMode
(TypeProtos.MinorType type, TypeProtos.DataMode mode) static TypeProtos.MajorType
withPrecision
(TypeProtos.MinorType type, TypeProtos.DataMode mode, int precision) Builds major type using given minor type, data mode and precision.static TypeProtos.MajorType
withPrecisionAndScale
(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_NAME
would 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 theprecision
of given type.- Parameters:
majorType
- major type- Returns:
- precision value
-
getScale
Get thescale
of 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:
true
if the two types have the same minor type and mode,false
otherwise
-
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
-