Package org.apache.druid.segment.column
Class ColumnType
- java.lang.Object
-
- org.apache.druid.segment.column.BaseTypeSignature<ValueType>
-
- org.apache.druid.segment.column.ColumnType
-
- All Implemented Interfaces:
TypeSignature<ValueType>
public class ColumnType extends BaseTypeSignature<ValueType>
Native Druid types.- See Also:
TypeSignature
-
-
Field Summary
Fields Modifier and Type Field Description static ColumnTypeDOUBLEDruid 64-bit double precision floating point number primitive type.static ColumnTypeDOUBLE_ARRAYAn array of Doubles.static ColumnTypeFLOATDruid 32-bit single precision floating point number primitive type.static ColumnTypeFLOAT_ARRAYAn array of Floats.static ColumnTypeLONGDruid 64-bit integer number primitive type.static ColumnTypeLONG_ARRAYAn array of Longs.static ColumnTypeNESTED_DATAstatic ColumnTypeSTRINGDruid string type.static ColumnTypeSTRING_ARRAYAn array of Strings.static ColumnTypeUNKNOWN_COMPLEXPlaceholder type for an "unknown" complex, which is used when the complex type name was "lost" or unavailable for whatever reason, to indicate an opaque type that cannot be generically handled with normal complex type handling mechanisms.-
Fields inherited from class org.apache.druid.segment.column.BaseTypeSignature
complexTypeName, elementType, type
-
-
Constructor Summary
Constructors Constructor Description ColumnType(ValueType type, String complexTypeName, ColumnType elementType)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ColumnTypefromString(String typeName)static ColumnTypeleastRestrictiveType(ColumnType type, ColumnType other)Finds the type that can best represent both types, or none if there is no type information.static ColumnTypeofArray(ColumnType elementType)static ColumnTypeofComplex(String complexTypeName)-
Methods inherited from class org.apache.druid.segment.column.BaseTypeSignature
equals, getComplexTypeName, getElementType, getNullableStrategy, getStrategy, getType, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.druid.segment.column.TypeSignature
anyOf, asTypeString, is, isArray, isNumeric, isPrimitive, isPrimitiveArray
-
-
-
-
Field Detail
-
STRING
public static final ColumnType STRING
Druid string type. Values will be represented asStringorListin the case of multi-value string columns.ColumnTypehas insufficient information to distinguish between single and multi-value strings, this requires a specificTypeSignatureimplementation which is supplied by segments, 'ColumnCapabilities', which is available at a higher layer and provides the method 'hasMultipleValues'.- See Also:
ValueType.STRING
-
LONG
public static final ColumnType LONG
Druid 64-bit integer number primitive type. Values will be represented as Java long orLong.- See Also:
ValueType.LONG
-
DOUBLE
public static final ColumnType DOUBLE
Druid 64-bit double precision floating point number primitive type. Values will be represented as Java double orDouble.- See Also:
ValueType.DOUBLE
-
FLOAT
public static final ColumnType FLOAT
Druid 32-bit single precision floating point number primitive type. Values will be represented as Java float orFloat.- See Also:
ValueType.FLOAT
-
STRING_ARRAY
public static final ColumnType STRING_ARRAY
An array of Strings. Values will be represented as Object[]- See Also:
ValueType.ARRAY,ValueType.STRING
-
LONG_ARRAY
public static final ColumnType LONG_ARRAY
An array of Longs. Values will be represented as Object[] or long[]- See Also:
ValueType.ARRAY,ValueType.LONG
-
DOUBLE_ARRAY
public static final ColumnType DOUBLE_ARRAY
An array of Doubles. Values will be represented as Object[] or double[].- See Also:
ValueType.ARRAY,ValueType.DOUBLE
-
FLOAT_ARRAY
public static final ColumnType FLOAT_ARRAY
An array of Floats. Values will be represented as Object[] or float[].- See Also:
ValueType.ARRAY,ValueType.FLOAT
-
NESTED_DATA
public static final ColumnType NESTED_DATA
-
UNKNOWN_COMPLEX
public static final ColumnType UNKNOWN_COMPLEX
Placeholder type for an "unknown" complex, which is used when the complex type name was "lost" or unavailable for whatever reason, to indicate an opaque type that cannot be generically handled with normal complex type handling mechanisms. Prefer to use aColumnTypewith theBaseTypeSignature.complexTypeNameset for most complex type matters if at all possible.- See Also:
ValueType.COMPLEX
-
-
Constructor Detail
-
ColumnType
public ColumnType(ValueType type, @Nullable String complexTypeName, @Nullable ColumnType elementType)
-
-
Method Detail
-
fromString
@Nullable public static ColumnType fromString(@Nullable String typeName)
-
ofArray
public static ColumnType ofArray(ColumnType elementType)
-
ofComplex
public static ColumnType ofComplex(@Nullable String complexTypeName)
-
leastRestrictiveType
@Nullable public static ColumnType leastRestrictiveType(@Nullable ColumnType type, @Nullable ColumnType other) throws Types.IncompatibleTypeException
Finds the type that can best represent both types, or none if there is no type information. If either type is null, the other type is returned. If both types are null, this method returns null as we cannot determine any useful type information. If the types areValueType.COMPLEX, they must be the same complex type, else this function throws aIllegalArgumentExceptionas the types are truly incompatible, with the exception ofNESTED_DATAwhich is complex and represents nested AND mixed type data so is instead treated as the 'least restrictive type' if present. If both types areValueType.ARRAY, the result is an array of the result of calling this method again onBaseTypeSignature.elementType. If only one type is an array, the result is an array type of calling this method on the non-array type and the array element type. After arrays, if either type isValueType.STRING, the result isValueType.STRING. If both types are numeric, then the result will beValueType.LONGif both are longs,ValueType.FLOATif both are floats, elseValueType.DOUBLE.
-
-