use of org.apache.drill.exec.physical.config.Filter in project drill by axbaretto.
the class TestNullInputMiniPlan method testFilterEmpty.
@Test
public void testFilterEmpty() throws Exception {
final PhysicalOperator filter = new Filter(null, parseExpr("a=5"), 1.0f);
testSingleInputNullBatchHandling(filter);
}
use of org.apache.drill.exec.physical.config.Filter in project drill by axbaretto.
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.EMPTY_LIST)).addInput(leftFilter).addInput(rightFilter).build();
BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.VARCHAR).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(batch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
use of org.apache.drill.exec.physical.config.Filter in project drill by axbaretto.
the class TestOpSerialization method testSerializedDeserialize.
@Test
public void testSerializedDeserialize() throws Throwable {
MockSubScanPOP s = new MockSubScanPOP("abc", false, null);
s.setOperatorId(3);
Filter f = new Filter(s, new ValueExpressions.BooleanExpression("true", ExpressionPosition.UNKNOWN), 0.1f);
f.setOperatorId(2);
UnionExchange e = new UnionExchange(f);
e.setOperatorId(1);
Screen screen = new Screen(e, CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
screen.setOperatorId(0);
boolean reversed = false;
while (true) {
List<PhysicalOperator> pops = Lists.newArrayList();
pops.add(s);
pops.add(e);
pops.add(f);
pops.add(screen);
if (reversed) {
pops = Lists.reverse(pops);
}
PhysicalPlan plan1 = new PhysicalPlan(PlanProperties.builder().build(), pops);
String json = plan1.unparse(writer);
PhysicalPlan plan2 = reader.readPhysicalPlan(json);
PhysicalOperator root = plan2.getSortedOperators(false).iterator().next();
assertEquals(0, root.getOperatorId());
PhysicalOperator o1 = root.iterator().next();
assertEquals(1, o1.getOperatorId());
PhysicalOperator o2 = o1.iterator().next();
assertEquals(2, o2.getOperatorId());
if (reversed) {
break;
}
reversed = !reversed;
}
}
use of org.apache.drill.exec.physical.config.Filter in project drill by apache.
the class TestOpSerialization method testSerializedDeserialize.
@Test
public void testSerializedDeserialize() throws Throwable {
MockSubScanPOP s = new MockSubScanPOP("abc", false, null);
s.setOperatorId(3);
Filter f = new Filter(s, new ValueExpressions.BooleanExpression("true", ExpressionPosition.UNKNOWN), 0.1f);
f.setOperatorId(2);
UnionExchange e = new UnionExchange(f);
e.setOperatorId(1);
Screen screen = new Screen(e, CoordinationProtos.DrillbitEndpoint.getDefaultInstance());
screen.setOperatorId(0);
boolean reversed = false;
while (true) {
List<PhysicalOperator> pops = Lists.newArrayList();
pops.add(s);
pops.add(e);
pops.add(f);
pops.add(screen);
if (reversed) {
pops = Lists.reverse(pops);
}
PhysicalPlan plan1 = new PhysicalPlan(PlanProperties.builder().build(), pops);
String json = plan1.unparse(writer);
PhysicalPlan plan2 = reader.readPhysicalPlan(json);
PhysicalOperator root = plan2.getSortedOperators(false).iterator().next();
assertEquals(0, root.getOperatorId());
PhysicalOperator o1 = root.iterator().next();
assertEquals(1, o1.getOperatorId());
PhysicalOperator o2 = o1.iterator().next();
assertEquals(2, o2.getOperatorId());
if (reversed) {
break;
}
reversed = !reversed;
}
}
use of org.apache.drill.exec.physical.config.Filter in project drill by apache.
the class TestFilterBatchEmitOutcome method testFilterEmptyBatchEmitOutcome.
/**
* Test to show if an empty batch is accompanied with EMIT outcome then Filter operator is not ignoring it and
* asking for next batch with data. Instead it is just returning the empty batch along with EMIT outcome right away.
*
* This test also shows that if first batch accompanied with OK_NEW_SCHEMA is empty then it is also pass through by
* Filter operator rather than ignoring it and waiting for a batch with some data in it.
* @throws Throwable
*/
@Test
public void testFilterEmptyBatchEmitOutcome() throws Throwable {
inputContainer.add(emptyInputRowSet.container());
inputContainer.add(emptyInputRowSet.container());
inputOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
inputOutcomes.add(RecordBatch.IterOutcome.EMIT);
final MockRecordBatch mockInputBatch = new MockRecordBatch(operatorFixture.getFragmentContext(), opContext, inputContainer, inputOutcomes, emptyInputRowSet.container().getSchema());
final Filter filterConf = new Filter(null, parseExpr("id_left=5"), 1.0f);
final FilterRecordBatch filterRecordBatch = new FilterRecordBatch(filterConf, mockInputBatch, operatorFixture.getFragmentContext());
assertTrue(filterRecordBatch.next() == RecordBatch.IterOutcome.OK_NEW_SCHEMA);
outputRecordCount += filterRecordBatch.getRecordCount();
assertTrue(filterRecordBatch.next() == RecordBatch.IterOutcome.EMIT);
outputRecordCount += filterRecordBatch.getRecordCount();
assertEquals(0, outputRecordCount);
}
Aggregations