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());
}
Aggregations