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
Modifier and TypeFieldDescriptionprotected final TypeProtos.DataMode
protected final String
protected final int
protected final int
protected final TypeProtos.MinorType
Fields 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_SUFFIX
Fields inherited from interface org.apache.drill.exec.record.metadata.Propertied
DRILL_PROP_PREFIX
-
Constructor Summary
ConstructorDescriptionAbstractColumnMetadata
(String name, TypeProtos.MajorType majorType) AbstractColumnMetadata
(String name, TypeProtos.MinorType type, TypeProtos.DataMode mode) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
bind
(TupleMetadata parentTuple) Schema of inner dimension forMULTI_ARRAY
columns.Converts column metadata into string representation accepted by the table schema parser.static AbstractColumnMetadata
createColumnMetadata
(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.int
boolean
boolean
boolean
protected String
escapeSpecialSymbols
(String value) If given value contains backticks (`) or backslashes (\), escapes them.int
Returns the expected array cardinality for array columns, or 1 for non-array columns.int
Get the expected width for a column.format()
boolean
isArray()
boolean
isDict()
boolean
Reports if the column is dynamic.boolean
Report whether one column is equivalent to another.boolean
isMap()
boolean
Determine if the schema represents a column with a LIST type with UNION elements.boolean
boolean
isScalar()
boolean
boolean
mode()
name()
int
Returns precision for current column.int
scale()
Returns scale for current column.void
setDefaultValue
(String value) Sets the default value property using the string-encoded form of the value.void
setExpectedElementCount
(int childCount) For an array column, specify the expected average array cardinality.void
setExpectedWidth
(int width) For variable-width columns, specify the expected column width to be used when allocating a new vector.void
toString()
Schema forTUPLE
columns.type()
abstract String
Converts type metadata into string representation accepted by the table schema parser.valueFromString
(String value) valueToString
(Object value) Schema forVARIANT
columns.Methods inherited from class org.apache.drill.exec.record.metadata.AbstractPropertied
booleanProperty, booleanProperty, hashCode, hasProperties, intProperty, intProperty, property, property, removeProperty, setBooleanProperty, setIntProperty, setProperties, setProperty
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.drill.exec.record.metadata.ColumnMetadata
cloneEmpty, copy, emptySchema, schema, structureType
Methods 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:
bind
in interfaceColumnMetadata
-
name
- Specified by:
name
in interfaceColumnMetadata
-
type
- Specified by:
type
in interfaceColumnMetadata
-
majorType
- Specified by:
majorType
in interfaceColumnMetadata
-
mode
- Specified by:
mode
in interfaceColumnMetadata
-
isNullable
public boolean isNullable()- Specified by:
isNullable
in interfaceColumnMetadata
-
isArray
public boolean isArray()- Specified by:
isArray
in interfaceColumnMetadata
-
dimensions
public int dimensions()- Specified by:
dimensions
in interfaceColumnMetadata
-
isMap
public boolean isMap()- Specified by:
isMap
in interfaceColumnMetadata
-
isVariant
public boolean isVariant()- Specified by:
isVariant
in interfaceColumnMetadata
-
isMultiList
public boolean isMultiList()Description copied from interface:ColumnMetadata
Determine 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:
isMultiList
in interfaceColumnMetadata
- Returns:
- true if the column is of type LIST of UNIONs
-
isDict
public boolean isDict()- Specified by:
isDict
in interfaceColumnMetadata
-
isScalar
public boolean isScalar()- Specified by:
isScalar
in interfaceColumnMetadata
-
isDynamic
public boolean isDynamic()Description copied from interface:ColumnMetadata
Reports 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:
isDynamic
in interfaceColumnMetadata
- Returns:
true
if the column does not yet have a concrete type,false
if the column type is concrete
-
tupleSchema
Description copied from interface:ColumnMetadata
Schema forTUPLE
columns.- Specified by:
tupleSchema
in interfaceColumnMetadata
- Returns:
- the tuple schema
-
variantSchema
Description copied from interface:ColumnMetadata
Schema forVARIANT
columns.- Specified by:
variantSchema
in interfaceColumnMetadata
- Returns:
- the variant schema
-
childSchema
Description copied from interface:ColumnMetadata
Schema of inner dimension forMULTI_ARRAY
columns. If an array is 3D, the outer column represents all 3 dimensions.outer.childSchema()
gives anotherMULTI_ARRAY
for 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:
childSchema
in interfaceColumnMetadata
- Returns:
- the description of the (n-1) st dimension.
-
isVariableWidth
public boolean isVariableWidth()- Specified by:
isVariableWidth
in interfaceColumnMetadata
-
isEquivalent
Description copied from interface:ColumnMetadata
Report 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:
isEquivalent
in interfaceColumnMetadata
-
equalsWithProperties
-
expectedWidth
public int expectedWidth()Description copied from interface:ColumnMetadata
Get 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:
expectedWidth
in 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:ColumnMetadata
For variable-width columns, specify the expected column width to be used when allocating a new vector. Does nothing for fixed-width columns.- Specified by:
setExpectedWidth
in 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:
precision
in 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:
scale
in interfaceColumnMetadata
- Returns:
- scale for current column
-
setExpectedElementCount
public void setExpectedElementCount(int childCount) Description copied from interface:ColumnMetadata
For an array column, specify the expected average array cardinality. Ignored for non-array columns. Used when allocating new vectors.- Specified by:
setExpectedElementCount
in 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:ColumnMetadata
Returns the expected array cardinality for array columns, or 1 for non-array columns.- Specified by:
expectedElementCount
in interfaceColumnMetadata
- Returns:
- the expected value cardinality per value (per-row for top-level columns, per array element for arrays within lists)
-
setFormat
- Specified by:
setFormat
in interfaceColumnMetadata
-
format
- Specified by:
format
in interfaceColumnMetadata
-
dateTimeFormatter
Description copied from interface:ColumnMetadata
Returns the formatter to use for date/time values. Only valid for date/time columns.- Specified by:
dateTimeFormatter
in interfaceColumnMetadata
- Returns:
-
setDefaultValue
Description copied from interface:ColumnMetadata
Sets 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:
setDefaultValue
in interfaceColumnMetadata
- Parameters:
value
- the default value in String representation
-
defaultValue
Description copied from interface:ColumnMetadata
Returns the default value for this column in String literal representation.- Specified by:
defaultValue
in interfaceColumnMetadata
- Returns:
- the default value in String literal representation, or null if no default value has been set
-
decodeDefaultValue
Description copied from interface:ColumnMetadata
Returns the default value decoded into object form. This is the same as:decodeValue(defaultValue());
- Specified by:
decodeDefaultValue
in interfaceColumnMetadata
- Returns:
- the default value decode as an object that can be passed to
the
ColumnWriter#setObject()
method.
-
valueFromString
- Specified by:
valueFromString
in interfaceColumnMetadata
-
valueToString
- Specified by:
valueToString
in interfaceColumnMetadata
-
properties
- Specified by:
properties
in interfacePropertied
- Overrides:
properties
in classAbstractPropertied
-
toString
-
appendContents
-
typeString
Description copied from interface:ColumnMetadata
Converts type metadata into string representation accepted by the table schema parser.- Specified by:
typeString
in interfaceColumnMetadata
- Returns:
- type metadata string representation
-
columnString
Description copied from interface:ColumnMetadata
Converts column metadata into string representation accepted by the table schema parser.- Specified by:
columnString
in interfaceColumnMetadata
- Returns:
- column metadata string representation
-
equals
- Overrides:
equals
in classAbstractPropertied
-
equalsWithProperties
-
escapeSpecialSymbols
If given value contains backticks (`) or backslashes (\), escapes them.- Parameters:
value
- string value- Returns:
- updated value
-