Search in sources :

Example 81 with ColumnMetadata

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

the class TestSchemaConversion method testStructSchema.

@Test
public void testStructSchema() {
    ColumnMetadata expectedSchema = new SchemaBuilder().addMap("a").addNullable("t1", TypeProtos.MinorType.BIT).addNullable("t2", TypeProtos.MinorType.INT).resumeSchema().buildSchema().metadata(0);
    verifyConversion("struct<t1:boolean,t2:int>", expectedSchema);
    expectedSchema = new SchemaBuilder().addMap("a").addNullable("t1", TypeProtos.MinorType.BIT).addMap("t2").addNullable("t3", TypeProtos.MinorType.VARDECIMAL, 38, 8).resumeMap().resumeSchema().buildSchema().metadata(0);
    verifyConversion("struct<t1:boolean,t2:struct<t3:decimal(38,8)>>", expectedSchema);
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 82 with ColumnMetadata

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

the class TestSchemaConversion method testRepeatedStructSchema.

@Test
public void testRepeatedStructSchema() {
    ColumnMetadata expectedSchema = new SchemaBuilder().addMapArray("a").addNullable("t1", TypeProtos.MinorType.VARCHAR, 999).addNullable("t2", TypeProtos.MinorType.INT).resumeSchema().buildSchema().metadata(0);
    verifyConversion("array<struct<t1:varchar(999),t2:int>>", expectedSchema);
    expectedSchema = new SchemaBuilder().addRepeatedList("a").addMapArray().addNullable("t1", TypeProtos.MinorType.VARCHAR, 999).addNullable("t2", TypeProtos.MinorType.INT).resumeList().resumeSchema().buildSchema().metadata(0);
    verifyConversion("array<array<struct<t1:varchar(999),t2:int>>>", expectedSchema);
    expectedSchema = new SchemaBuilder().addRepeatedList("a").addDimension().addMapArray().addRepeatedList("t1").addArray(TypeProtos.MinorType.VARCHAR, 999).resumeMap().addArray("t2", TypeProtos.MinorType.VARDECIMAL, 28, 14).resumeList().resumeList().resumeSchema().buildSchema().metadata(0);
    verifyConversion("array<array<array<struct<t1:array<array<varchar(999)>>,t2:array<decimal(28,14)>>>>>", expectedSchema);
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 83 with ColumnMetadata

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

the class TestSchemaConversion method testRepeatedSchema.

@Test
public void testRepeatedSchema() {
    verifyConversion("array<boolean>", Types.repeated(TypeProtos.MinorType.BIT));
    ColumnMetadata expectedSchema = new SchemaBuilder().addRepeatedList("a").addArray(TypeProtos.MinorType.BIT).resumeSchema().buildSchema().metadata(0);
    verifyConversion("array<array<boolean>>", expectedSchema);
    expectedSchema = new SchemaBuilder().addRepeatedList("a").addDimension().addArray(TypeProtos.MinorType.BIT).resumeList().resumeSchema().buildSchema().metadata(0);
    verifyConversion("array<array<array<boolean>>>", expectedSchema);
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) PrimitiveColumnMetadata(org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 84 with ColumnMetadata

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

the class InferredFieldFactory method repeatedListOfVariantListenerFor.

/**
 * Create a RepeatedList which contains Unions. (Actually, this is an
 * array of List objects internally.) The variant is variable, it makes no
 * sense to specify a schema for the variant. Also, omitting the schema
 * save a large amount of complexity that will likely never be needed.
 */
@SuppressWarnings("unused")
private ElementParser repeatedListOfVariantListenerFor(FieldDefn fieldDefn) {
    ColumnMetadata innerSchema = MetadataUtils.newVariant(fieldDefn.key(), DataMode.REPEATED);
    int dims = fieldDefn.lookahead().dimensions();
    ColumnMetadata fieldSchema = repeatedListSchemaFor(fieldDefn.key(), dims, innerSchema);
    return multiDimVariantArrayParserFor(fieldDefn.fieldWriterFor(fieldSchema), dims);
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata)

Example 85 with ColumnMetadata

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

the class ProvidedFieldFactory method variantParserForSchema.

private ElementParser variantParserForSchema(FieldDefn fieldDefn) {
    // A variant can contain multiple types. The schema does not
    // declare the types; rather they are discovered by the reader.
    // That is, there is no VARIANT<INT, DOUBLE>, there is just VARIANT.
    ColumnMetadata colSchema = fieldDefn.providedColumn().cloneEmpty();
    ObjectWriter fieldWriter = fieldDefn.fieldWriterFor(colSchema);
    if (colSchema.isArray()) {
        return variantArrayParserFor(fieldWriter.array());
    } else {
        return variantParserFor(fieldWriter.variant());
    }
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) ObjectWriter(org.apache.drill.exec.vector.accessor.ObjectWriter)

Aggregations

ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)195 Test (org.junit.Test)104 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)98 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)50 DrillTest (org.apache.drill.test.DrillTest)37 PrimitiveColumnMetadata (org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata)31 SubOperatorTest (org.apache.drill.test.SubOperatorTest)31 BaseTest (org.apache.drill.test.BaseTest)26 MapColumnMetadata (org.apache.drill.exec.record.metadata.MapColumnMetadata)20 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)20 VariantColumnMetadata (org.apache.drill.exec.record.metadata.VariantColumnMetadata)19 VariantMetadata (org.apache.drill.exec.record.metadata.VariantMetadata)19 AbstractColumnMetadata (org.apache.drill.exec.record.metadata.AbstractColumnMetadata)17 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)17 DictColumnMetadata (org.apache.drill.exec.record.metadata.DictColumnMetadata)15 EvfTest (org.apache.drill.categories.EvfTest)13 ProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter)13 TupleSchema (org.apache.drill.exec.record.metadata.TupleSchema)11 ArrayList (java.util.ArrayList)10 ProjResult (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.ProjResult)10