Search in sources :

Example 6 with Filter

use of org.apache.drill.exec.physical.config.Filter 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();
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) BatchSchemaBuilder(org.apache.drill.exec.record.BatchSchemaBuilder) UnionAll(org.apache.drill.exec.physical.config.UnionAll) Test(org.junit.Test)

Example 7 with Filter

use of org.apache.drill.exec.physical.config.Filter in project drill by apache.

the class TestNullInputMiniPlan method testFilterEmpty.

@Test
public void testFilterEmpty() throws Exception {
    final PhysicalOperator filter = new Filter(null, parseExpr("a=5"), 1.0f);
    testSingleInputNullBatchHandling(filter);
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Test(org.junit.Test)

Example 8 with Filter

use of org.apache.drill.exec.physical.config.Filter in project drill by apache.

the class BasicPhysicalOpUnitTest method testFilter.

@Test
public void testFilter() {
    Filter filterConf = new Filter(null, parseExpr("a=5"), 1.0f);
    List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]", "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
    legacyOpTestBuilder().physicalOperator(filterConf).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b").baselineValues(5l, 1l).baselineValues(5l, 5l).go();
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) Test(org.junit.Test)

Example 9 with Filter

use of org.apache.drill.exec.physical.config.Filter in project drill by axbaretto.

the class FilterPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    Filter p = new Filter(childPOP, getFilterExpression(new DrillParseContext(PrelUtil.getSettings(getCluster()))), 1.0f);
    return creator.addMetadata(this, p);
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext)

Example 10 with Filter

use of org.apache.drill.exec.physical.config.Filter in project drill by axbaretto.

the class BasicPhysicalOpUnitTest method testFilter.

@Test
public void testFilter() {
    Filter filterConf = new Filter(null, parseExpr("a=5"), 1.0f);
    List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]", "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
    opTestBuilder().physicalOperator(filterConf).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b").baselineValues(5l, 1l).baselineValues(5l, 5l).go();
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) Test(org.junit.Test)

Aggregations

Filter (org.apache.drill.exec.physical.config.Filter)19 Test (org.junit.Test)17 OperatorTest (org.apache.drill.categories.OperatorTest)6 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)6 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)6 UnionAll (org.apache.drill.exec.physical.config.UnionAll)5 BatchSchema (org.apache.drill.exec.record.BatchSchema)5 RecordBatch (org.apache.drill.exec.record.RecordBatch)5 PlannerTest (org.apache.drill.categories.PlannerTest)2 ValueExpressions (org.apache.drill.common.expression.ValueExpressions)2 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)2 Screen (org.apache.drill.exec.physical.config.Screen)2 UnionExchange (org.apache.drill.exec.physical.config.UnionExchange)2 DrillParseContext (org.apache.drill.exec.planner.logical.DrillParseContext)2 BatchSchemaBuilder (org.apache.drill.exec.record.BatchSchemaBuilder)2 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)2 MockSubScanPOP (org.apache.drill.exec.store.mock.MockSubScanPOP)2 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)2 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)1 BaseTest (org.apache.drill.test.BaseTest)1