Interface ColumnMetadata
- All Superinterfaces:
Propertied
- All Known Implementing Classes:
AbstractColumnMetadata
,AbstractMapColumnMetadata
,DictColumnMetadata
,DynamicColumn
,MapColumnMetadata
,PrimitiveColumnMetadata
,ProjectedColumn
,RepeatedListColumnMetadata
,VariantColumnMetadata
Metadata description of a column including names, types and structure
information.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Rough characterization of Drill types into metadata categories. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Convert blanks to null values (if the column is nullable), or fill with the default value (non-nullable.)static final String
Indicates how to handle blanks.static final String
Convert blanks for numeric fields to 0.static final int
static final String
Default value represented as a string.static final String
Indicates whether to project the column in a wildcard (*) query.static final String
Predicted number of elements per array entry.static final String
Expected (average) width for variable-width columns.static final String
Optional format to use when converting to/from string values.static final String
Indicates that a provided schema column is an implicit column (one defined by Drill rather than the reader.) Allows the implicit schema to reify partition names, say, as reader-specific names.static final String
File name implicit column type.static final String
File path implicit column type.static final String
Fully-qualified name implicit column type.static final String
Prefix for partition directories.static final String
File suffix implicit column type.Fields inherited from interface org.apache.drill.exec.record.metadata.Propertied
DRILL_PROP_PREFIX
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(TupleMetadata parentTuple) Schema of inner dimension forMULTI_ARRAY
columns.Create an empty version of this column.Converts column metadata into string representation accepted by the table schema parser.copy()
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
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
isEquivalent
(ColumnMetadata other) 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
int
scale()
schema()
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
Schema forTUPLE
columns.type()
Converts type metadata into string representation accepted by the table schema parser.valueFromString
(String value) valueToString
(Object value) Schema forVARIANT
columns.Methods inherited from interface org.apache.drill.exec.record.metadata.Propertied
booleanProperty, booleanProperty, hasProperties, intProperty, intProperty, properties, property, property, removeProperty, setBooleanProperty, setIntProperty, setProperties, setProperty
-
Field Details
-
EXPECTED_CARDINALITY_PROP
Predicted number of elements per array entry. Default is taken from the often hard-coded value of 10.- See Also:
-
DEFAULT_VALUE_PROP
Default value represented as a string.- See Also:
-
EXPECTED_WIDTH_PROP
Expected (average) width for variable-width columns.- See Also:
-
FORMAT_PROP
Optional format to use when converting to/from string values.- See Also:
-
BLANK_AS_PROP
Indicates how to handle blanks. Must be one of the valid values defined in AbstractConvertFromString. Normally set on the converter by the plugin rather than by the user in the schema.- See Also:
-
BLANK_AS_NULL
Convert blanks to null values (if the column is nullable), or fill with the default value (non-nullable.)- See Also:
-
BLANK_AS_ZERO
Convert blanks for numeric fields to 0. For non-numeric fields, convert to null (for nullable) or the default value (for non-nullable). Works best if non-numeric fields are declared as nullable.- See Also:
-
EXCLUDE_FROM_WILDCARD
Indicates whether to project the column in a wildcard (*) query. Special columns may be excluded from projection. Certain "special" columns may be available only when explicitly requested. For example, the log reader has a "_raw" column which includes the entire input line before parsing. This column can be requested explicitly:
SELECT foo, bar, _raw FROM ...
but the column will not be included when using the wildcard:
SELECT * FROM ...
Marking a column (either in the provided schema or the reader schema) will prevent that column from appearing in a wildcard expansion.
- See Also:
-
DEFAULT_ARRAY_SIZE
static final int DEFAULT_ARRAY_SIZE- See Also:
-
IMPLICIT_COL_TYPE
Indicates that a provided schema column is an implicit column (one defined by Drill rather than the reader.) Allows the implicit schema to reify partition names, say, as reader-specific names. For example,dir0
might be reified asyear
, etc.Available when the underlying reader supports implicit columns. The value is the defined implicit column name (not the name set via system/session options.) Using the defined name makes the provided schema immune from runtime changes to column names.
As the result of adding this feature, any column not tagged as implicit is a reader column, even if that column happens to have the same (currently selected runtime) name as an implicit column.
- See Also:
-
IMPLICIT_FQN
Fully-qualified name implicit column type.- See Also:
-
IMPLICIT_FILEPATH
File path implicit column type.- See Also:
-
IMPLICIT_FILENAME
File name implicit column type.- See Also:
-
IMPLICIT_SUFFIX
File suffix implicit column type.- See Also:
-
IMPLICIT_PARTITION_PREFIX
Prefix for partition directories. dir0 is the table root folder, dir1 the first subdirectory, and so on. Directories that don't exist in the actual file path take aNULL
value.- See Also:
-
-
Method Details
-
structureType
ColumnMetadata.StructureType structureType() -
tupleSchema
TupleMetadata tupleSchema()Schema forTUPLE
columns.- Returns:
- the tuple schema
-
variantSchema
VariantMetadata variantSchema()Schema forVARIANT
columns.- Returns:
- the variant schema
-
childSchema
ColumnMetadata childSchema()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.
- Returns:
- the description of the (n-1) st dimension.
-
schema
MaterializedField schema() -
emptySchema
MaterializedField emptySchema() -
name
String name() -
type
TypeProtos.MinorType type() -
majorType
TypeProtos.MajorType majorType() -
mode
TypeProtos.DataMode mode() -
dimensions
int dimensions() -
isNullable
boolean isNullable() -
isArray
boolean isArray() -
isVariableWidth
boolean isVariableWidth() -
isMap
boolean isMap() -
isVariant
boolean isVariant() -
isDict
boolean isDict() -
isScalar
boolean isScalar() -
isDynamic
boolean isDynamic()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.- Returns:
true
if the column does not yet have a concrete type,false
if the column type is concrete
-
isMultiList
boolean isMultiList()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.)- Returns:
- true if the column is of type LIST of UNIONs
-
isEquivalent
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.) -
setExpectedWidth
void setExpectedWidth(int width) For variable-width columns, specify the expected column width to be used when allocating a new vector. Does nothing for fixed-width columns.- Parameters:
width
- the expected column width
-
expectedWidth
int expectedWidth()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.- 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
-
setExpectedElementCount
void setExpectedElementCount(int childCount) For an array column, specify the expected average array cardinality. Ignored for non-array columns. Used when allocating new vectors.- Parameters:
childCount
- the expected average array cardinality. Defaults to 1 for non-array columns, 10 for array columns
-
expectedElementCount
int expectedElementCount()Returns the expected array cardinality for array columns, or 1 for non-array columns.- Returns:
- the expected value cardinality per value (per-row for top-level columns, per array element for arrays within lists)
-
setFormat
-
format
String format() -
dateTimeFormatter
DateTimeFormatter dateTimeFormatter()Returns the formatter to use for date/time values. Only valid for date/time columns.- Returns:
-
setDefaultValue
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.- Parameters:
value
- the default value in String representation
-
defaultValue
String defaultValue()Returns the default value for this column in String literal representation.- Returns:
- the default value in String literal representation, or null if no default value has been set
-
decodeDefaultValue
Object decodeDefaultValue()Returns the default value decoded into object form. This is the same as:decodeValue(defaultValue());
- Returns:
- the default value decode as an object that can be passed to
the
ColumnWriter#setObject()
method.
-
valueToString
-
valueFromString
-
cloneEmpty
ColumnMetadata cloneEmpty()Create an empty version of this column. If the column is a scalar, produces a simple copy. If a map, produces a clone without child columns.- Returns:
- empty clone of this column
-
precision
int precision() -
scale
int scale() -
bind
-
copy
ColumnMetadata copy() -
typeString
String typeString()Converts type metadata into string representation accepted by the table schema parser.- Returns:
- type metadata string representation
-
columnString
String columnString()Converts column metadata into string representation accepted by the table schema parser.- Returns:
- column metadata string representation
-