Interface TupleMetadata

All Superinterfaces:
Iterable<ColumnMetadata>, Propertied
All Known Implementing Classes:
TupleSchema

public interface TupleMetadata extends Propertied, Iterable<ColumnMetadata>
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.
This form is useful when performing semantic analysis and when working with vectors.

In the future, this structure will also gather metadata useful for vector processing such as expected widths and so on.

  • Field Details

    • WRITER

      static final com.fasterxml.jackson.databind.ObjectWriter WRITER
    • READER

      static final com.fasterxml.jackson.databind.ObjectReader READER
    • IS_STRICT_SCHEMA_PROP

      static final String 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

      int addColumn(ColumnMetadata column)
    • size

      int size()
    • isEmpty

      boolean isEmpty()
    • index

      int index(String name)
    • metadata

      ColumnMetadata metadata(int index)
    • metadata

      ColumnMetadata metadata(String name)
    • column

      MaterializedField column(int index)
    • column

      MaterializedField column(String name)
    • isEquivalent

      boolean isEquivalent(TupleMetadata other)
    • 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

      String fullName(ColumnMetadata column)
      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

      String fullName(int index)
    • copy

    • replace

      void replace(ColumnMetadata replaceWith)
    • jsonString

      default String jsonString()
      Converts current TupleMetadata implementation into JSON string representation.
      Returns:
      tuple metadata in JSON string representation
      Throws:
      IllegalStateException - if unable to convert current instance into JSON string
    • of

      static TupleMetadata of(String jsonString)
      Converts given JSON string into TupleMetadata 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