Search in sources :

Example 1 with MapColumnMetadata

use of org.apache.drill.exec.record.metadata.MapColumnMetadata in project drill by axbaretto.

the class TestTupleSchema method testRepeatedMapColumn.

@Test
public void testRepeatedMapColumn() {
    MaterializedField field = SchemaBuilder.columnSchema("m", MinorType.MAP, DataMode.REPEATED);
    ColumnMetadata col = MetadataUtils.fromField(field);
    assertTrue(col instanceof MapColumnMetadata);
    assertNotNull(col.mapSchema());
    assertEquals(0, col.mapSchema().size());
    assertFalse(col.isNullable());
    assertTrue(col.isArray());
    assertFalse(col.isVariableWidth());
    assertTrue(col.isMap());
    assertFalse(col.isVariant());
    assertEquals(0, col.expectedWidth());
    col.setExpectedWidth(10);
    assertEquals(0, col.expectedWidth());
    assertEquals(ColumnMetadata.DEFAULT_ARRAY_SIZE, col.expectedElementCount());
    col.setExpectedElementCount(2);
    assertEquals(2, col.expectedElementCount());
}
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) MapColumnMetadata(org.apache.drill.exec.record.metadata.MapColumnMetadata) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 2 with MapColumnMetadata

use of org.apache.drill.exec.record.metadata.MapColumnMetadata in project drill by axbaretto.

the class TestTupleSchema method testMapColumn.

/**
 * Tests a map column. Maps can only be required or repeated, not nullable.
 * (But, the columns in the map can be nullable.)
 */
@Test
public void testMapColumn() {
    MaterializedField field = SchemaBuilder.columnSchema("m", MinorType.MAP, DataMode.REQUIRED);
    ColumnMetadata col = MetadataUtils.fromField(field);
    assertTrue(col instanceof MapColumnMetadata);
    assertNotNull(col.mapSchema());
    assertEquals(0, col.mapSchema().size());
    assertSame(col, col.mapSchema().parent());
    MapColumnMetadata mapCol = (MapColumnMetadata) col;
    assertNull(mapCol.parentTuple());
    assertEquals(ColumnMetadata.StructureType.TUPLE, col.structureType());
    assertFalse(col.isNullable());
    assertFalse(col.isArray());
    assertFalse(col.isVariableWidth());
    assertTrue(col.isMap());
    assertFalse(col.isVariant());
    assertEquals(0, col.expectedWidth());
    col.setExpectedWidth(10);
    assertEquals(0, col.expectedWidth());
    assertEquals(1, col.expectedElementCount());
    col.setExpectedElementCount(2);
    assertEquals(1, col.expectedElementCount());
}
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) MapColumnMetadata(org.apache.drill.exec.record.metadata.MapColumnMetadata) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Aggregations

ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)2 MapColumnMetadata (org.apache.drill.exec.record.metadata.MapColumnMetadata)2 PrimitiveColumnMetadata (org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata)2 VariantColumnMetadata (org.apache.drill.exec.record.metadata.VariantColumnMetadata)2 SubOperatorTest (org.apache.drill.test.SubOperatorTest)2 Test (org.junit.Test)2