use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.
the class TestNullInputMiniPlan method testHashJoinRightEmpty.
@Test
public void testHashJoinRightEmpty() throws Exception {
List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
RecordBatch right = createScanBatchFromJson(SINGLE_EMPTY_JSON);
RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "a2")), JoinRelType.INNER)).addInput(leftScan).addInput(right).build();
BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.
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();
RecordBatch scanBatch = new ParquetScanBuilder().fileSystem(fs).columnsToRead("R_REGIONKEY").inputPaths(Lists.newArrayList(file)).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();
BatchSchema expectedSchema = new SchemaBuilder().add("regionkey", TypeProtos.MinorType.BIGINT).build();
new MiniPlanTestBuilder().root(unionBatch).expectSchema(expectedSchema).baselineValues(10L).baselineValues(11L).go();
}
use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.
the class TestNullInputMiniPlan method testLeftHashJoinLeftEmpty.
@Test
public void testLeftHashJoinLeftEmpty() throws Exception {
RecordBatch left = createScanBatchFromJson(SINGLE_EMPTY_JSON);
List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
RecordBatch rightScan = new JsonScanBuilder().jsonBatches(rightJsonBatches).columnsToRead("a", "b").build();
RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "a2")), JoinRelType.LEFT)).addInput(left).addInput(rightScan).build();
BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.
the class TestNullInputMiniPlan method testJsonInputMixedWithEmptyFiles2.
/**
* Test ScanBatch with mixed json files.
* input is empty, empty, data_file, data_file
*/
@Test
public void testJsonInputMixedWithEmptyFiles2() throws Exception {
RecordBatch scanBatch = createScanBatchFromJson(SINGLE_EMPTY_JSON, SINGLE_EMPTY_JSON2, SINGLE_JSON, SINGLE_JSON2);
BatchSchema expectedSchema = new SchemaBuilder().addNullable("id", TypeProtos.MinorType.BIGINT).addNullable("name", TypeProtos.MinorType.VARCHAR).build();
new MiniPlanTestBuilder().root(scanBatch).expectSchema(expectedSchema).baselineValues(100L, "John").baselineValues(1000L, "Joe").expectBatchNum(2).go();
}
use of org.apache.drill.test.rowSet.schema.SchemaBuilder in project drill by axbaretto.
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);
BatchSchema expectedSchema = new SchemaBuilder().addNullable("col1", TypeProtos.MinorType.INT).addNullable("col2", TypeProtos.MinorType.INT).add("col3", TypeProtos.MinorType.FLOAT8).addNullable("col4", TypeProtos.MinorType.VARCHAR, 100).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();
}
Aggregations