Class AbstractColumnMetadata
java.lang.Object
org.apache.drill.exec.record.metadata.AbstractPropertied
org.apache.drill.exec.record.metadata.AbstractColumnMetadata
- All Implemented Interfaces:
ColumnMetadata,Propertied
- Direct Known Subclasses:
AbstractMapColumnMetadata,DynamicColumn,PrimitiveColumnMetadata,RepeatedListColumnMetadata,VariantColumnMetadata
Abstract definition of column metadata. Allows applications to create
specialized forms of a column metadata object by extending from this abstract
class.
Note that, by design, primitive columns do not have a link to their tuple parent, or their index within that parent. This allows the same metadata to be shared between two views of a tuple, perhaps physical and projected views. This restriction does not apply to map columns, since maps (and the row itself) will, by definition, differ between the two views.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.drill.exec.record.metadata.ColumnMetadata
ColumnMetadata.StructureType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TypeProtos.DataModeprotected final Stringprotected final intprotected final intprotected final TypeProtos.MinorTypeFields inherited from interface org.apache.drill.exec.record.metadata.ColumnMetadata
BLANK_AS_NULL, BLANK_AS_PROP, BLANK_AS_ZERO, DEFAULT_ARRAY_SIZE, DEFAULT_VALUE_PROP, EXCLUDE_FROM_WILDCARD, EXPECTED_CARDINALITY_PROP, EXPECTED_WIDTH_PROP, FORMAT_PROP, IMPLICIT_COL_TYPE, IMPLICIT_FILENAME, IMPLICIT_FILEPATH, IMPLICIT_FQN, IMPLICIT_PARTITION_PREFIX, IMPLICIT_SUFFIXFields inherited from interface org.apache.drill.exec.record.metadata.Propertied
DRILL_PROP_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionAbstractColumnMetadata(String name, TypeProtos.MajorType majorType) AbstractColumnMetadata(String name, TypeProtos.MinorType type, TypeProtos.DataMode mode) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidbind(TupleMetadata parentTuple) Schema of inner dimension forMULTI_ARRAYcolumns.Converts column metadata into string representation accepted by the table schema parser.static AbstractColumnMetadatacreateColumnMetadata(String name, String type, TypeProtos.DataMode mode, Map<String, String> properties) Returns the formatter to use for date/time values.Returns the default value decoded into object form.Returns the default value for this column in String literal representation.intbooleanbooleanbooleanprotected StringescapeSpecialSymbols(String value) If given value contains backticks (`) or backslashes (\), escapes them.intReturns the expected array cardinality for array columns, or 1 for non-array columns.intGet the expected width for a column.format()booleanisArray()booleanisDict()booleanReports if the column is dynamic.booleanReport whether one column is equivalent to another.booleanisMap()booleanDetermine if the schema represents a column with a LIST type with UNION elements.booleanbooleanisScalar()booleanbooleanmode()name()intReturns precision for current column.intscale()Returns scale for current column.voidsetDefaultValue(String value) Sets the default value property using the string-encoded form of the value.voidsetExpectedElementCount(int childCount) For an array column, specify the expected average array cardinality.voidsetExpectedWidth(int width) For variable-width columns, specify the expected column width to be used when allocating a new vector.voidtoString()Schema forTUPLEcolumns.type()abstract StringConverts type metadata into string representation accepted by the table schema parser.valueFromString(String value) valueToString(Object value) Schema forVARIANTcolumns.Methods inherited from class org.apache.drill.exec.record.metadata.AbstractPropertied
booleanProperty, booleanProperty, hashCode, hasProperties, intProperty, intProperty, property, property, removeProperty, setBooleanProperty, setIntProperty, setProperties, setPropertyMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.drill.exec.record.metadata.ColumnMetadata
cloneEmpty, copy, emptySchema, schema, structureTypeMethods inherited from interface org.apache.drill.exec.record.metadata.Propertied
booleanProperty, booleanProperty, hasProperties, intProperty, intProperty, property, property, removeProperty, setBooleanProperty, setIntProperty, setProperties, setProperty
-
Field Details
-
name
-
type
-
mode
-
precision
protected final int precision -
scale
protected final int scale
-
-
Constructor Details
-
AbstractColumnMetadata
-
AbstractColumnMetadata
-
AbstractColumnMetadata
-
AbstractColumnMetadata
-
-
Method Details
-
createColumnMetadata
public static AbstractColumnMetadata createColumnMetadata(String name, String type, TypeProtos.DataMode mode, Map<String, String> properties) throws IOException- Throws:
IOException
-
bind
- Specified by:
bindin interfaceColumnMetadata
-
name
- Specified by:
namein interfaceColumnMetadata
-
type
- Specified by:
typein interfaceColumnMetadata
-
majorType
- Specified by:
majorTypein interfaceColumnMetadata
-
mode
- Specified by:
modein interfaceColumnMetadata
-
isNullable
public boolean isNullable()- Specified by:
isNullablein interfaceColumnMetadata
-
isArray
public boolean isArray()- Specified by:
isArrayin interfaceColumnMetadata
-
dimensions
public int dimensions()- Specified by:
dimensionsin interfaceColumnMetadata
-
isMap
public boolean isMap()- Specified by:
isMapin interfaceColumnMetadata
-
isVariant
public boolean isVariant()- Specified by:
isVariantin interfaceColumnMetadata
-
isMultiList
public boolean isMultiList()Description copied from interface:ColumnMetadataDetermine if the schema represents a column with a LIST type with UNION elements. (Lists can be of a single type (with nullable elements) or can be of unions.)- Specified by:
isMultiListin interfaceColumnMetadata- Returns:
- true if the column is of type LIST of UNIONs
-
isDict
public boolean isDict()- Specified by:
isDictin interfaceColumnMetadata
-
isScalar
public boolean isScalar()- Specified by:
isScalarin interfaceColumnMetadata
-
isDynamic
public boolean isDynamic()Description copied from interface:ColumnMetadataReports if the column is dynamic. A dynamic column is one with a "type to be named later." It is valid for describing a dynamic schema, but not for creating vectors; to create a vector the column must be resolved to a concrete type. The context should make it clear if any columns can be dynamic.- Specified by:
isDynamicin interfaceColumnMetadata- Returns:
trueif the column does not yet have a concrete type,falseif the column type is concrete
-
tupleSchema
Description copied from interface:ColumnMetadataSchema forTUPLEcolumns.- Specified by:
tupleSchemain interfaceColumnMetadata- Returns:
- the tuple schema
-
variantSchema
Description copied from interface:ColumnMetadataSchema forVARIANTcolumns.- Specified by:
variantSchemain interfaceColumnMetadata- Returns:
- the variant schema
-
childSchema
Description copied from interface:ColumnMetadataSchema of inner dimension forMULTI_ARRAYcolumns. If an array is 3D, the outer column represents all 3 dimensions.outer.childSchema()gives anotherMULTI_ARRAYfor the inner 2D array.outer.childSchema().childSchema()gives a column of some other type (but repeated) for the 1D array.Sorry for the mess, but it is how the code works and we are not in a position to revisit data type fundamentals.
- Specified by:
childSchemain interfaceColumnMetadata- Returns:
- the description of the (n-1) st dimension.
-
isVariableWidth
public boolean isVariableWidth()- Specified by:
isVariableWidthin interfaceColumnMetadata
-
isEquivalent
Description copied from interface:ColumnMetadataReport whether one column is equivalent to another. Columns are equivalent if they have the same name, type and structure (ignoring internal structure such as properties.)- Specified by:
isEquivalentin interfaceColumnMetadata
-
equalsWithProperties
-
expectedWidth
public int expectedWidth()Description copied from interface:ColumnMetadataGet the expected width for a column. This is the actual width for fixed- width columns, the specified width (defaulting to 50) for variable-width columns.- Specified by:
expectedWidthin interfaceColumnMetadata- Returns:
- the expected column width of the each data value. Does not include "overhead" space such as for the null-value vector or offset vector
-
setExpectedWidth
public void setExpectedWidth(int width) Description copied from interface:ColumnMetadataFor variable-width columns, specify the expected column width to be used when allocating a new vector. Does nothing for fixed-width columns.- Specified by:
setExpectedWidthin interfaceColumnMetadata- Parameters:
width- the expected column width
-
precision
public int precision()Returns precision for current column. For the case when precision is not set or column type does not support precision, negative value will be returned.- Specified by:
precisionin interfaceColumnMetadata- Returns:
- precision for current column
-
scale
public int scale()Returns scale for current column. For the case when scale is not set or column type does not support scale, negative value will be returned.- Specified by:
scalein interfaceColumnMetadata- Returns:
- scale for current column
-
setExpectedElementCount
public void setExpectedElementCount(int childCount) Description copied from interface:ColumnMetadataFor an array column, specify the expected average array cardinality. Ignored for non-array columns. Used when allocating new vectors.- Specified by:
setExpectedElementCountin interfaceColumnMetadata- Parameters:
childCount- the expected average array cardinality. Defaults to 1 for non-array columns, 10 for array columns
-
expectedElementCount
public int expectedElementCount()Description copied from interface:ColumnMetadataReturns the expected array cardinality for array columns, or 1 for non-array columns.- Specified by:
expectedElementCountin interfaceColumnMetadata- Returns:
- the expected value cardinality per value (per-row for top-level columns, per array element for arrays within lists)
-
setFormat
- Specified by:
setFormatin interfaceColumnMetadata
-
format
- Specified by:
formatin interfaceColumnMetadata
-
dateTimeFormatter
Description copied from interface:ColumnMetadataReturns the formatter to use for date/time values. Only valid for date/time columns.- Specified by:
dateTimeFormatterin interfaceColumnMetadata- Returns:
-
setDefaultValue
Description copied from interface:ColumnMetadataSets the default value property using the string-encoded form of the value. The default value is used for filling a vector when no real data is available.- Specified by:
setDefaultValuein interfaceColumnMetadata- Parameters:
value- the default value in String representation
-
defaultValue
Description copied from interface:ColumnMetadataReturns the default value for this column in String literal representation.- Specified by:
defaultValuein interfaceColumnMetadata- Returns:
- the default value in String literal representation, or null if no default value has been set
-
decodeDefaultValue
Description copied from interface:ColumnMetadataReturns the default value decoded into object form. This is the same as:decodeValue(defaultValue());- Specified by:
decodeDefaultValuein interfaceColumnMetadata- Returns:
- the default value decode as an object that can be passed to
the
method.
invalid reference
ColumnWriter#setObject()
-
valueFromString
- Specified by:
valueFromStringin interfaceColumnMetadata
-
valueToString
- Specified by:
valueToStringin interfaceColumnMetadata
-
properties
- Specified by:
propertiesin interfacePropertied- Overrides:
propertiesin classAbstractPropertied
-
toString
-
appendContents
-
typeString
Description copied from interface:ColumnMetadataConverts type metadata into string representation accepted by the table schema parser.- Specified by:
typeStringin interfaceColumnMetadata- Returns:
- type metadata string representation
-
columnString
Description copied from interface:ColumnMetadataConverts column metadata into string representation accepted by the table schema parser.- Specified by:
columnStringin interfaceColumnMetadata- Returns:
- column metadata string representation
-
equals
- Overrides:
equalsin classAbstractPropertied
-
equalsWithProperties
-
escapeSpecialSymbols
If given value contains backticks (`) or backslashes (\), escapes them.- Parameters:
value- string value- Returns:
- updated value
-