Interface TupleMetadata
- All Superinterfaces:
Iterable<ColumnMetadata>
,Propertied
- All Known Implementing Classes:
TupleSchema
Metadata description of the schema of a row or a map.
In Drill, both rows and maps are
tuples: both are an ordered collection of values, defined by a
schema. Each tuple has a schema that defines the column ordering
for indexed access. Each tuple also provides methods to get column
accessors by name or index.
Models the physical schema of a row set showing the logical hierarchy of fields with map fields as first-class fields. Map members appear as children under the map, much as they appear in the physical value-vector implementation.
- Provides fast lookup by name or index.
- Provides a nested schema, in this same form, for maps.
In the future, this structure will also gather metadata useful for vector processing such as expected widths and so on.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final com.fasterxml.jackson.databind.ObjectReader
static final com.fasterxml.jackson.databind.ObjectWriter
Fields inherited from interface org.apache.drill.exec.record.metadata.Propertied
DRILL_PROP_PREFIX
-
Method Summary
Modifier and TypeMethodDescriptionadd
(MaterializedField field) Add a new column to the schema.int
addColumn
(ColumnMetadata column) column
(int index) copy()
fullName
(int index) fullName
(ColumnMetadata column) Full name of the column.int
boolean
isEmpty()
boolean
isEquivalent
(TupleMetadata other) default String
Converts currentTupleMetadata
implementation into JSON string representation.metadata
(int index) static TupleMetadata
Converts given JSON string intoTupleMetadata
instance.parent()
void
replace
(ColumnMetadata replaceWith) int
size()
Return the schema as a list of MaterializedField objects which can be used to create other schemas.Returns schema as list of ColumnMetadata objects which can be used to create JSON schema object.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
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
-
WRITER
static final com.fasterxml.jackson.databind.ObjectWriter WRITER -
READER
static final com.fasterxml.jackson.databind.ObjectReader READER -
IS_STRICT_SCHEMA_PROP
- See Also:
-
-
Method Details
-
add
Add a new column to the schema.- Parameters:
field
- materialized field- Returns:
- the index of the new column
-
addColumn
-
size
int size() -
isEmpty
boolean isEmpty() -
index
-
metadata
-
metadata
-
column
-
column
-
isEquivalent
-
parent
ColumnMetadata parent() -
toFieldList
List<MaterializedField> toFieldList()Return the schema as a list of MaterializedField objects which can be used to create other schemas. Not valid for a flattened schema.- Returns:
- a list of the top-level fields. Maps contain their child fields
-
toMetadataList
List<ColumnMetadata> toMetadataList()Returns schema as list of ColumnMetadata objects which can be used to create JSON schema object.- Returns:
- a list of metadata for each column
-
fullName
Full name of the column. Note: this name cannot be used to look up the column because of ambiguity. The name "a.b.c" may mean a single column with that name, or may mean maps "a", and "b" with column "c", etc.- Returns:
- full, dotted, column name
-
fullName
-
copy
TupleMetadata copy() -
replace
-
jsonString
Converts currentTupleMetadata
implementation into JSON string representation.- Returns:
- tuple metadata in JSON string representation
- Throws:
IllegalStateException
- if unable to convert current instance into JSON string
-
of
Converts given JSON string intoTupleMetadata
instance.TupleMetadata
implementation is determined by present type property. For example: "type":"tuple_schema". If given JSON string is untyped, used default implementation:TupleSchema
.- Parameters:
jsonString
- tuple metadata in JSON string representation- Returns:
TupleMetadata
instance, null if given JSON string is null or empty- Throws:
IllegalArgumentException
- if unable to deserialize given JSON string
-