Search in sources :

Example 31 with SchemaBuilder

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();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) Test(org.junit.Test)

Example 32 with SchemaBuilder

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();
}
Also used : Project(org.apache.drill.exec.physical.config.Project) BatchSchema(org.apache.drill.exec.record.BatchSchema) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) UnionAll(org.apache.drill.exec.physical.config.UnionAll) Test(org.junit.Test)

Example 33 with SchemaBuilder

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();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) Test(org.junit.Test)

Example 34 with SchemaBuilder

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();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Test(org.junit.Test)

Example 35 with SchemaBuilder

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();
}
Also used : Project(org.apache.drill.exec.physical.config.Project) BatchSchema(org.apache.drill.exec.record.BatchSchema) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) Test(org.junit.Test)

Aggregations

SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)175 Test (org.junit.Test)154 BatchSchema (org.apache.drill.exec.record.BatchSchema)102 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)91 SubOperatorTest (org.apache.drill.test.SubOperatorTest)86 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)65 RowSet (org.apache.drill.test.rowSet.RowSet)52 RowSetReader (org.apache.drill.test.rowSet.RowSetReader)50 ResultSetLoader (org.apache.drill.exec.physical.rowSet.ResultSetLoader)38 RowSetLoader (org.apache.drill.exec.physical.rowSet.RowSetLoader)38 ScalarReader (org.apache.drill.exec.vector.accessor.ScalarReader)26 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)25 DrillTest (org.apache.drill.test.DrillTest)21 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)20 ScalarWriter (org.apache.drill.exec.vector.accessor.ScalarWriter)18 RowSetBuilder (org.apache.drill.test.rowSet.RowSetBuilder)18 ScalarElementReader (org.apache.drill.exec.vector.accessor.ScalarElementReader)17 AbstractColumnMetadata (org.apache.drill.exec.record.metadata.AbstractColumnMetadata)16 TupleWriter (org.apache.drill.exec.vector.accessor.TupleWriter)16 RecordBatch (org.apache.drill.exec.record.RecordBatch)14