use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by axbaretto.
the class TestSchemaBuilder method testRepeatedListInRow.
/**
* Test building a repeated list in the top-level schema.
*/
@Test
public void testRepeatedListInRow() {
TupleMetadata schema = new SchemaBuilder().addRepeatedList("list").addArray(MinorType.VARCHAR).resumeSchema().buildSchema();
assertEquals(1, schema.size());
ColumnMetadata list = schema.metadata(0);
assertEquals("list", list.name());
assertFalse(list.isVariant());
assertEquals(StructureType.MULTI_ARRAY, list.structureType());
assertEquals(MinorType.LIST, list.type());
// See note above for the (non-repeated) list.
assertEquals(DataMode.REPEATED, list.mode());
ColumnMetadata child = list.childSchema();
assertNotNull(child);
assertEquals(list.name(), child.name());
assertEquals(MinorType.VARCHAR, child.type());
assertEquals(DataMode.REPEATED, child.mode());
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by axbaretto.
the class TestSchemaBuilder method testMapInRow.
/**
* Tests creating a map within a row.
* Also the basic map add column methods.
*/
@Test
public void testMapInRow() {
TupleMetadata schema = new SchemaBuilder().addMap("m").add("a", MinorType.VARCHAR, // Generic
DataMode.OPTIONAL).add("b", // Required
MinorType.INT).addNullable("c", // Convenience
MinorType.FLOAT8).addArray("d", // Convenience
MinorType.BIGINT).resumeSchema().buildSchema();
assertEquals(1, schema.size());
ColumnMetadata m = schema.metadata(0);
assertEquals("m", m.name());
assertTrue(m.isMap());
assertEquals(DataMode.REQUIRED, m.mode());
TupleMetadata mapSchema = m.mapSchema();
assertNotNull(mapSchema);
assertEquals(4, mapSchema.size());
ColumnMetadata a = mapSchema.metadata(0);
assertEquals("a", a.name());
assertEquals(MinorType.VARCHAR, a.type());
assertEquals(DataMode.OPTIONAL, a.mode());
ColumnMetadata b = mapSchema.metadata(1);
assertEquals("b", b.name());
assertEquals(MinorType.INT, b.type());
assertEquals(DataMode.REQUIRED, b.mode());
ColumnMetadata c = mapSchema.metadata(2);
assertEquals("c", c.name());
assertEquals(MinorType.FLOAT8, c.type());
assertEquals(DataMode.OPTIONAL, c.mode());
ColumnMetadata d = mapSchema.metadata(3);
assertEquals("d", d.name());
assertEquals(MinorType.BIGINT, d.type());
assertEquals(DataMode.REPEATED, d.mode());
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by axbaretto.
the class TestSchemaBuilder method testMapInRepeatedList.
// Note: union-in-union not supported in Drill
@Test
public void testMapInRepeatedList() {
TupleMetadata schema = new SchemaBuilder().addRepeatedList("x").addMapArray().add("a", MinorType.INT).addNullable("b", MinorType.VARCHAR).resumeList().resumeSchema().buildSchema();
ColumnMetadata list = schema.metadata("x");
ColumnMetadata mapCol = list.childSchema();
assertTrue(mapCol.isMap());
TupleMetadata mapSchema = mapCol.mapSchema();
ColumnMetadata a = mapSchema.metadata("a");
assertEquals(MinorType.INT, a.type());
assertEquals(DataMode.REQUIRED, a.mode());
ColumnMetadata b = mapSchema.metadata("b");
assertEquals(MinorType.VARCHAR, b.type());
assertEquals(DataMode.OPTIONAL, b.mode());
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by axbaretto.
the class TestSchemaBuilder method testMapInMap.
/**
* Verify that the map-in-map plumbing works.
*/
@Test
public void testMapInMap() {
TupleMetadata schema = new SchemaBuilder().addMap("m1").addMap("m2").add("a", MinorType.INT).resumeMap().add("b", MinorType.VARCHAR).resumeSchema().buildSchema();
TupleMetadata m1Schema = schema.metadata("m1").mapSchema();
TupleMetadata m2Schema = m1Schema.metadata("m2").mapSchema();
ColumnMetadata a = m2Schema.metadata(0);
assertEquals("a", a.name());
assertEquals(MinorType.INT, a.type());
ColumnMetadata b = m1Schema.metadata(1);
assertEquals("b", b.name());
assertEquals(MinorType.VARCHAR, b.type());
}
use of org.apache.drill.exec.record.metadata.ColumnMetadata in project drill by axbaretto.
the class TestSchemaBuilder method testRepeatedListInRepeatedList.
/**
* Test that repeated lists can be nested to provide 3D or
* higher dimensions.
*/
@Test
public void testRepeatedListInRepeatedList() {
TupleMetadata schema = new SchemaBuilder().addRepeatedList("x").addDimension().addArray(MinorType.VARCHAR).resumeList().resumeSchema().buildSchema();
assertEquals(1, schema.size());
ColumnMetadata outerList = schema.metadata(0);
assertEquals("x", outerList.name());
assertEquals(StructureType.MULTI_ARRAY, outerList.structureType());
assertEquals(MinorType.LIST, outerList.type());
assertEquals(DataMode.REPEATED, outerList.mode());
ColumnMetadata innerList = outerList.childSchema();
assertNotNull(innerList);
assertEquals(outerList.name(), innerList.name());
assertEquals(StructureType.MULTI_ARRAY, innerList.structureType());
assertEquals(MinorType.LIST, innerList.type());
assertEquals(DataMode.REPEATED, innerList.mode());
ColumnMetadata child = innerList.childSchema();
assertNotNull(child);
assertEquals(outerList.name(), child.name());
assertEquals(MinorType.VARCHAR, child.type());
assertEquals(DataMode.REPEATED, child.mode());
}
Aggregations