use of org.apache.drill.common.exceptions.EmptyErrorContext in project drill by apache.
the class TestResultSetLoaderProjection method setupProvidedSchema.
// Setup to test the various project/provided schema cases in
// ProjectionFilter, especially CompoundProjectionFilter
public ResultSetLoader setupProvidedSchema(boolean isStrict, List<SchemaPath> selection) {
TupleMetadata schema = new SchemaBuilder().addMap("m1").add("a", MinorType.INT).add("b", MinorType.INT).resumeSchema().addMap("m2").add("c", MinorType.INT).add("d", MinorType.INT).resumeSchema().addMap("m3").add("e", MinorType.INT).add("f", MinorType.INT).resumeSchema().buildSchema();
// Provided schema: disjoint set of above.
TupleMetadata providedSchema = new SchemaBuilder().addMap(// Same
"m1").add("a", MinorType.INT).add("b", MinorType.INT).add("z", // Add a column
MinorType.INT).resumeSchema().addMap(// Omit c
"m2").add("d", MinorType.INT).resumeSchema().addMap(// Add m4
"m4").add("g", MinorType.INT).add("h", MinorType.INT).resumeSchema().build();
if (isStrict) {
SchemaUtils.markStrict(providedSchema);
}
RequestedTuple proj = Projections.parse(selection);
CustomErrorContext errorContext = new EmptyErrorContext();
ProjectionFilter projectionFilter = ProjectionFilter.providedSchemaFilter(proj, providedSchema, errorContext);
ResultSetOptions options = new ResultSetOptionBuilder().projectionFilter(projectionFilter).readerSchema(schema).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
// Write a couple of rows.
rsLoader.startBatch();
RowSetLoader rootWriter = rsLoader.writer();
rootWriter.start();
rootWriter.addRow(mapValue(1, 2), mapValue(3, 4), mapValue(5, 6)).addRow(mapValue(11, 12), mapValue(13, 14), mapValue(15, 16));
return rsLoader;
}
Aggregations