Search in sources :

Example 1 with ColumnBuilder

use of org.apache.drill.test.rowSet.schema.ColumnBuilder in project drill by axbaretto.

the class TestTupleSchema method testRequiredVariableWidthColumn.

@Test
public void testRequiredVariableWidthColumn() {
    MaterializedField field = SchemaBuilder.columnSchema("c", MinorType.VARCHAR, DataMode.REQUIRED);
    ColumnMetadata col = MetadataUtils.fromField(field);
    assertEquals(ColumnMetadata.StructureType.PRIMITIVE, col.structureType());
    assertNull(col.mapSchema());
    assertFalse(col.isNullable());
    assertFalse(col.isArray());
    assertTrue(col.isVariableWidth());
    assertFalse(col.isMap());
    assertFalse(col.isVariant());
    // A different precision is a different type.
    MaterializedField field2 = new ColumnBuilder("c", MinorType.VARCHAR).setMode(DataMode.REQUIRED).setPrecision(10).build();
    ColumnMetadata col2 = MetadataUtils.fromField(field2);
    assertFalse(col.isEquivalent(col2));
    assertEquals(50, col.expectedWidth());
    col.setExpectedWidth(10);
    assertEquals(10, col.expectedWidth());
    assertEquals(1, col.expectedElementCount());
    col.setExpectedElementCount(2);
    assertEquals(1, col.expectedElementCount());
    // If precision is provided, then that is the default width
    col = MetadataUtils.fromField(field2);
    assertEquals(10, col.expectedWidth());
}
Also used : MapColumnMetadata(org.apache.drill.exec.record.metadata.MapColumnMetadata) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) VariantColumnMetadata(org.apache.drill.exec.record.metadata.VariantColumnMetadata) ColumnBuilder(org.apache.drill.test.rowSet.schema.ColumnBuilder) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 MapColumnMetadata (org.apache.drill.exec.record.metadata.MapColumnMetadata)1 PrimitiveColumnMetadata (org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata)1 VariantColumnMetadata (org.apache.drill.exec.record.metadata.VariantColumnMetadata)1 SubOperatorTest (org.apache.drill.test.SubOperatorTest)1 ColumnBuilder (org.apache.drill.test.rowSet.schema.ColumnBuilder)1 Test (org.junit.Test)1