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