use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestOptiqPlans method testFilterPlan.
@Test
public void testFilterPlan() throws Exception {
final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (final Drillbit bit1 = new Drillbit(config, serviceSet);
final DrillClient client = new DrillClient(config, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Resources.toString(Resources.getResource("physical_filter.json"), Charsets.UTF_8));
final RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
for (final QueryDataBatch b : results) {
System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
loader.load(b.getHeader().getDef(), b.getData());
for (final VectorWrapper<?> vw : loader) {
System.out.println(vw.getValueVector().getField().getPath());
final ValueVector vv = vw.getValueVector();
for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
final Object o = vv.getAccessor().getObject(i);
System.out.println(o);
}
}
loader.clear();
b.release();
}
client.close();
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestOptiqPlans method testOrderVarbinary.
@Test
public void testOrderVarbinary() throws Exception {
final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (final Drillbit bit1 = new Drillbit(config, serviceSet);
final DrillClient client = new DrillClient(config, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Resources.toString(Resources.getResource("physical_order_varbinary.json"), Charsets.UTF_8));
final RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
for (final QueryDataBatch b : results) {
System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
loader.load(b.getHeader().getDef(), b.getData());
for (final VectorWrapper vw : loader) {
System.out.println(vw.getValueVector().getField().getPath());
final ValueVector vv = vw.getValueVector();
for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
final Object o = vv.getAccessor().getObject(i);
if (vv instanceof VarBinaryVector) {
final VarBinaryVector.Accessor x = ((VarBinaryVector) vv).getAccessor();
final VarBinaryHolder vbh = new VarBinaryHolder();
x.get(i, vbh);
System.out.printf("%d..%d", vbh.start, vbh.end);
System.out.println("[" + new String((byte[]) vv.getAccessor().getObject(i)) + "]");
} else {
System.out.println(vv.getAccessor().getObject(i));
}
}
}
loader.clear();
b.release();
}
client.close();
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestOptiqPlans method testFilterString.
@Test
public void testFilterString() throws Exception {
final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (final Drillbit bit1 = new Drillbit(config, serviceSet);
final DrillClient client = new DrillClient(config, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.LOGICAL, Resources.toString(Resources.getResource("logical_string_filter.json"), Charsets.UTF_8));
final RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
for (final QueryDataBatch b : results) {
System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
loader.load(b.getHeader().getDef(), b.getData());
for (final VectorWrapper<?> vw : loader) {
System.out.println(vw.getValueVector().getField().getPath());
final ValueVector vv = vw.getValueVector();
for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
final Object o = vv.getAccessor().getObject(i);
if (vv instanceof VarBinaryVector) {
final VarBinaryVector.Accessor x = ((VarBinaryVector) vv).getAccessor();
final VarBinaryHolder vbh = new VarBinaryHolder();
x.get(i, vbh);
System.out.printf("%d..%d", vbh.start, vbh.end);
System.out.println("[" + new String((byte[]) vv.getAccessor().getObject(i)) + "]");
} else {
System.out.println(vv.getAccessor().getObject(i));
}
}
}
loader.clear();
b.release();
}
client.close();
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestReverseImplicitCast method twoWayCast.
@Test
public void twoWayCast(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable {
// Function checks for casting from Float, Double to Decimal data types
try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
Drillbit bit = new Drillbit(CONFIG, serviceSet);
DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
// run query.
bit.run();
client.connect();
List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/functions/cast/two_way_implicit_cast.json"), Charsets.UTF_8));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
QueryDataBatch batch = results.get(0);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor();
ValueVector.Accessor varcharAccessor1 = itr.next().getValueVector().getAccessor();
for (int i = 0; i < intAccessor1.getValueCount(); i++) {
System.out.println(intAccessor1.getObject(i));
assertEquals(intAccessor1.getObject(i), 10);
System.out.println(varcharAccessor1.getObject(i));
assertEquals(varcharAccessor1.getObject(i).toString(), "101");
}
batchLoader.clear();
for (QueryDataBatch result : results) {
result.release();
}
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestConvertFunctions method testBigIntVarCharReturnTripConvertLogical.
// TODO(DRILL-2326) remove this when we get rid of the scalar replacement option test cases below
@Ignore
@Test
public void testBigIntVarCharReturnTripConvertLogical() throws Exception {
final String logicalPlan = Resources.toString(Resources.getResource(CONVERSION_TEST_LOGICAL_PLAN), Charsets.UTF_8);
final List<QueryDataBatch> results = testLogicalWithResults(logicalPlan);
int count = 0;
final RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
for (QueryDataBatch result : results) {
count += result.getHeader().getRowCount();
loader.load(result.getHeader().getDef(), result.getData());
if (loader.getRecordCount() > 0) {
VectorUtil.showVectorAccessibleContent(loader);
}
loader.clear();
result.release();
}
assertTrue(count == 10);
}
Aggregations