use of org.apache.drill.exec.record.RecordBatch in project drill by apache.
the class TestMiniPlan method testUnionFilter.
@Test
public void testUnionFilter() throws Exception {
List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]", "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 10 }]", "[{\"a\": 50, \"b\" : 100}]");
RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
new UnionAll(Collections.EMPTY_LIST)).addInputAsChild().physicalOperator(new Filter(null, parseExpr("a=5"), 1.0f)).addJsonScanAsChild().jsonBatches(leftJsonBatches).columnsToRead("a", "b").buildAddAsInput().buildAddAsInput().addInputAsChild().physicalOperator(new Filter(null, parseExpr("a=50"), 1.0f)).addJsonScanAsChild().jsonBatches(rightJsonBatches).columnsToRead("a", "b").buildAddAsInput().buildAddAsInput().build();
BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(batch).expectedSchema(expectedSchema).baselineValues(5l, 1l).baselineValues(5l, 5l).baselineValues(50l, 100l).go();
}
use of org.apache.drill.exec.record.RecordBatch in project drill by apache.
the class TestMiniPlan method testSimpleParquetScan.
@Test
public void testSimpleParquetScan() throws Exception {
String file = FileUtils.getResourceAsFile("/tpchmulti/region/01.parquet").toURI().toString();
RecordBatch scanBatch = new ParquetScanBuilder().fileSystem(fs).columnsToRead("R_REGIONKEY").inputPaths(Lists.newArrayList(file)).build();
BatchSchema expectedSchema = new SchemaBuilder().add("R_REGIONKEY", TypeProtos.MinorType.BIGINT).build();
new MiniPlanTestBuilder().root(scanBatch).expectedSchema(expectedSchema).baselineValues(0L).baselineValues(1L).go();
}
use of org.apache.drill.exec.record.RecordBatch in project drill by apache.
the class ExpressionInterpreterTest method createMockScanBatch.
@SuppressWarnings("resource")
private ScanBatch createMockScanBatch(Drillbit bit, MockSubScanPOP scanPOP, BitControl.PlanFragment planFragment) {
final List<RecordBatch> children = Lists.newArrayList();
final MockScanBatchCreator creator = new MockScanBatchCreator();
try {
final FragmentContext context = new FragmentContext(bit.getContext(), planFragment, null, bit.getContext().getFunctionImplementationRegistry());
return creator.getBatch(context, scanPOP, children);
} catch (Exception ex) {
throw new DrillRuntimeException("Error when setup fragment context" + ex);
}
}
use of org.apache.drill.exec.record.RecordBatch in project drill by apache.
the class ImplCreator method getRecordBatch.
/** Create a RecordBatch and its children for given PhysicalOperator */
@VisibleForTesting
public RecordBatch getRecordBatch(final PhysicalOperator op, final FragmentContext context) throws ExecutionSetupException {
Preconditions.checkNotNull(op);
final List<RecordBatch> childRecordBatches = getChildren(op, context);
if (context.isImpersonationEnabled()) {
final UserGroupInformation proxyUgi = ImpersonationUtil.createProxyUgi(op.getUserName(), context.getQueryUserName());
try {
return proxyUgi.doAs(new PrivilegedExceptionAction<RecordBatch>() {
@Override
public RecordBatch run() throws Exception {
final CloseableRecordBatch batch = ((BatchCreator<PhysicalOperator>) getOpCreator(op, context)).getBatch(context, op, childRecordBatches);
operators.addFirst(batch);
return batch;
}
});
} catch (InterruptedException | IOException e) {
final String errMsg = String.format("Failed to create RecordBatch for operator with id '%d'", op.getOperatorId());
logger.error(errMsg, e);
throw new ExecutionSetupException(errMsg, e);
}
} else {
final CloseableRecordBatch batch = ((BatchCreator<PhysicalOperator>) getOpCreator(op, context)).getBatch(context, op, childRecordBatches);
operators.addFirst(batch);
return batch;
}
}
Aggregations