Class SchemaBuilder

java.lang.Object
org.apache.drill.exec.record.metadata.SchemaBuilder

public class SchemaBuilder extends Object
Builder of a row set schema expressed as a list of materialized fields. Optimized for use when creating schemas by hand in tests.

Example usage to create the following schema:
(c: INT, a: MAP(b: VARCHAR, d: INT, e: MAP(f: VARCHAR), g: INT), h: UNION(INT, MAP(h1: INT), LIST(BIGINT)), i: BIGINT[], j: VARCHAR[][][])

Code:


     TupleMetadata schema = new SchemaBuilder()
        .add("c", MinorType.INT)
        .addMap("a")
          .addNullable("b", MinorType.VARCHAR)
          .add("d", MinorType.INT)
          .addMap("e") // or .addMapArray("e")
            .add("f", MinorType.VARCHAR)
            .resumeMap()
          .add("g", MinorType.INT)
          .resumeSchema()
        .addUnion("h") // or .addList("h")
          .addType(MinorType.INT)
          .addMap()
            .add("h1", MinorType.INT)
            .resumeUnion()
          .addList()
            .addType(MinorType.BIGINT)
            .resumeUnion()
          .resumeSchema()
        .addArray("i", MinorType.BIGINT)
        .addRepeatedList("j")
          .addDimension()
            .addArray(MinorType.VARCHAR)
            .resumeList()
         .resumeSchema()
        .buildSchema();
 </code