Search in sources :

Example 1 with RepeatedListBuilder

use of org.apache.drill.exec.record.metadata.RepeatedListBuilder in project drill by apache.

the class TestSchemaBuilder method testStandaloneRepeatedListBuilder.

@Test
public void testStandaloneRepeatedListBuilder() {
    ColumnMetadata columnMetadata = new RepeatedListBuilder("l").addMapArray().addNullable("v", MinorType.VARCHAR).add("i", MinorType.INT).resumeList().buildColumn();
    assertTrue(columnMetadata.isArray());
    assertEquals("l", columnMetadata.name());
    assertEquals(MinorType.LIST, columnMetadata.type());
    ColumnMetadata child = columnMetadata.childSchema();
    assertEquals("l", child.name());
    assertTrue(child.isArray());
    assertTrue(child.isMap());
    TupleMetadata mapSchema = child.tupleSchema();
    ColumnMetadata col0 = mapSchema.metadata(0);
    assertEquals("v", col0.name());
    assertEquals(MinorType.VARCHAR, col0.type());
    assertTrue(col0.isNullable());
    ColumnMetadata col1 = mapSchema.metadata(1);
    assertEquals("i", col1.name());
    assertEquals(MinorType.INT, col1.type());
    assertFalse(col1.isNullable());
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RepeatedListBuilder(org.apache.drill.exec.record.metadata.RepeatedListBuilder) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Aggregations

ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 RepeatedListBuilder (org.apache.drill.exec.record.metadata.RepeatedListBuilder)1 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)1 DrillTest (org.apache.drill.test.DrillTest)1 Test (org.junit.Test)1