use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testUnionFilterAll.
@Test
public void testUnionFilterAll() throws Exception {
List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : \"name1\" }]");
List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : \"name2\" }]");
RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
RecordBatch leftFilter = new PopBuilder().physicalOperator(new Filter(null, parseExpr("a < 0"), 1.0f)).addInput(leftScan).build();
RecordBatch rightScan = new JsonScanBuilder().jsonBatches(rightJsonBatches).columnsToRead("a", "b").build();
RecordBatch rightFilter = new PopBuilder().physicalOperator(new Filter(null, parseExpr("a < 0"), 1.0f)).addInput(rightScan).build();
RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
new UnionAll(Collections.emptyList())).addInput(leftFilter).addInput(rightFilter).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.VARCHAR);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(batch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testOutputProjectEmpty.
@Test
public void testOutputProjectEmpty() throws Exception {
final PhysicalOperator project = new Project(parseExprs("x", "col1", "x + 100", "col2", "100.0", "col3", "cast(nonExist as varchar(100))", "col4"), null, true);
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("col1", TypeProtos.MinorType.INT).addNullable("col2", TypeProtos.MinorType.INT).add("col3", TypeProtos.MinorType.FLOAT8).addNullable("col4", TypeProtos.MinorType.VARCHAR, 100);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
final RecordBatch input = createScanBatchFromJson(SINGLE_EMPTY_JSON);
RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
project).addInput(input).build();
new MiniPlanTestBuilder().root(batch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testJsonInputMixedWithEmptyFiles4.
/**
* Test ScanBatch with mixed json files.
* input is data_file, data_file, empty, empty
*/
@Test
public void testJsonInputMixedWithEmptyFiles4() throws Exception {
RecordBatch scanBatch = createScanBatchFromJson(SINGLE_JSON, SINGLE_JSON2, SINGLE_EMPTY_JSON2, SINGLE_EMPTY_JSON2);
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("id", TypeProtos.MinorType.BIGINT).addNullable("name", TypeProtos.MinorType.VARCHAR);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
new MiniPlanTestBuilder().root(scanBatch).expectSchema(expectedSchema).baselineValues(100L, "John").baselineValues(1000L, "Joe").expectBatchNum(2).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testUnionLeftEmtpy.
@Test
public void testUnionLeftEmtpy() throws Exception {
// Children list is provided through RecordBatch
final PhysicalOperator unionAll = new UnionAll(Collections.EMPTY_LIST);
RecordBatch left = createScanBatchFromJson(SINGLE_EMPTY_JSON);
String file = DrillFileUtils.getResourceAsFile("/tpchmulti/region/01.parquet").toURI().toString();
List<Path> filePath = Collections.singletonList(new Path(file));
RecordBatch scanBatch = new ParquetScanBuilder().fileSystem(fs).columnsToRead("R_REGIONKEY").inputPaths(filePath).build();
RecordBatch projectBatch = new PopBuilder().physicalOperator(new Project(parseExprs("R_REGIONKEY+10", "regionkey"), null)).addInput(scanBatch).build();
RecordBatch unionBatch = new PopBuilder().physicalOperator(unionAll).addInput(left).addInput(projectBatch).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().add("regionkey", TypeProtos.MinorType.BIGINT);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
new MiniPlanTestBuilder().root(unionBatch).expectSchema(expectedSchema).baselineValues(10L).baselineValues(11L).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestMiniPlan method testSimpleJson.
@Test
public void testSimpleJson() throws Exception {
List<String> jsonBatches = Lists.newArrayList("{\"a\":100}");
RecordBatch scanBatch = new JsonScanBuilder().jsonBatches(jsonBatches).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
new MiniPlanTestBuilder().root(scanBatch).expectSchema(expectedSchema).baselineValues(100L).go();
}
Aggregations