use of org.apache.drill.exec.record.metadata.AbstractColumnMetadata in project drill by axbaretto.
the class TupleState method addColumn.
/**
* Implementation of the work to add a new column to this tuple given a
* schema description of the column.
*
* @param columnSchema schema of the column
* @return writer for the new column
*/
private AbstractObjectWriter addColumn(ColumnMetadata columnSchema) {
// Indicate projection in the metadata.
((AbstractColumnMetadata) columnSchema).setProjected(projectionSet.isProjected(columnSchema.name()));
// Build the column
ColumnState colState;
if (columnSchema.isMap()) {
colState = buildMap(columnSchema);
} else {
colState = buildPrimitive(columnSchema);
}
columns.add(colState);
colState.updateCardinality(innerCardinality());
colState.allocateVectors();
return colState.writer();
}
use of org.apache.drill.exec.record.metadata.AbstractColumnMetadata in project drill by axbaretto.
the class TestSchemaBuilder method testRowPreBuilt.
@Test
public void testRowPreBuilt() {
MaterializedField aField = MaterializedField.create("a", Types.optional(MinorType.VARCHAR));
AbstractColumnMetadata bCol = MetadataUtils.newScalar("b", MinorType.INT, DataMode.REQUIRED);
SchemaBuilder builder = new SchemaBuilder().add(aField);
// Internal method, does not return builder itself.
builder.addColumn(bCol);
TupleMetadata schema = builder.buildSchema();
assertEquals(2, schema.size());
ColumnMetadata a = schema.metadata(0);
assertEquals("a", a.name());
assertEquals(MinorType.VARCHAR, a.type());
assertEquals(DataMode.OPTIONAL, a.mode());
ColumnMetadata b = schema.metadata(1);
assertEquals("b", b.name());
assertEquals(MinorType.INT, b.type());
assertEquals(DataMode.REQUIRED, b.mode());
}
Aggregations