Search in sources :

Example 1 with AbstractColumnMetadata

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();
}
Also used : MapArrayColumnState(org.apache.drill.exec.physical.rowSet.impl.ColumnState.MapArrayColumnState) BaseMapColumnState(org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState) MapColumnState(org.apache.drill.exec.physical.rowSet.impl.ColumnState.MapColumnState) AbstractColumnMetadata(org.apache.drill.exec.record.metadata.AbstractColumnMetadata)

Example 2 with AbstractColumnMetadata

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());
}
Also used : AbstractColumnMetadata(org.apache.drill.exec.record.metadata.AbstractColumnMetadata) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) MaterializedField(org.apache.drill.exec.record.MaterializedField) AbstractColumnMetadata(org.apache.drill.exec.record.metadata.AbstractColumnMetadata) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

Aggregations

AbstractColumnMetadata (org.apache.drill.exec.record.metadata.AbstractColumnMetadata)2 BaseMapColumnState (org.apache.drill.exec.physical.rowSet.impl.ColumnState.BaseMapColumnState)1 MapArrayColumnState (org.apache.drill.exec.physical.rowSet.impl.ColumnState.MapArrayColumnState)1 MapColumnState (org.apache.drill.exec.physical.rowSet.impl.ColumnState.MapColumnState)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)1 DrillTest (org.apache.drill.test.DrillTest)1 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)1 Test (org.junit.Test)1