use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class DrillClientSystemTest method testSubmitPlanSingleNode.
@Test
public void testSubmitPlanSingleNode() throws Exception {
startCluster(1);
DrillClient client = new DrillClient();
client.connect();
List<QueryDataBatch> results = client.runQuery(QueryType.LOGICAL, plan);
for (QueryDataBatch result : results) {
System.out.println(result);
result.release();
}
client.close();
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestMultiInputAdd method testMultiInputAdd.
@Test
public void testMultiInputAdd() throws Throwable {
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(DrillFileUtils.getResourceAsFile("/functions/multi_input_add_test.json"), Charsets.UTF_8));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
QueryDataBatch batch = results.get(0);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
for (VectorWrapper<?> v : batchLoader) {
ValueVector.Accessor accessor = v.getValueVector().getAccessor();
assertTrue((accessor.getObject(0)).equals(10));
}
batchLoader.clear();
for (QueryDataBatch b : results) {
b.release();
}
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestAggregateFunctions method minMaxEmptyNonNullableInput.
@Test
public void minMaxEmptyNonNullableInput() throws Exception {
// test min and max functions on required type
final QueryDataBatch result = testSqlWithResults("select * from cp.`parquet/alltypes_required.parquet` limit 0").get(0);
final Map<String, StringBuilder> functions = Maps.newHashMap();
functions.put("min", new StringBuilder());
functions.put("max", new StringBuilder());
final Map<String, Object> resultingValues = Maps.newHashMap();
for (UserBitShared.SerializedField field : result.getHeader().getDef().getFieldList()) {
final String fieldName = field.getNamePart().getName();
// Only COUNT aggregate function supported for Boolean type
if (fieldName.equals("col_bln")) {
continue;
}
resultingValues.put(String.format("`%s`", fieldName), null);
for (Map.Entry<String, StringBuilder> function : functions.entrySet()) {
function.getValue().append(function.getKey()).append("(").append(fieldName).append(") ").append(fieldName).append(",");
}
}
result.release();
final String query = "select %s from cp.`parquet/alltypes_required.parquet` where 1 = 0";
final List<Map<String, Object>> baselineRecords = Lists.newArrayList();
baselineRecords.add(resultingValues);
for (StringBuilder selectBody : functions.values()) {
selectBody.setLength(selectBody.length() - 1);
testBuilder().sqlQuery(query, selectBody.toString()).unOrdered().baselineRecords(baselineRecords).go();
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestSimpleTopN method sortOneKeyAscending.
@Test
public void sortOneKeyAscending() throws Throwable {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit1.run();
bit2.run();
client.connect();
List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/topN/one_key_sort.json"), Charsets.UTF_8));
int count = 0;
for (QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
}
assertEquals(100, count);
long previousBigInt = Long.MIN_VALUE;
int recordCount = 0;
int batchCount = 0;
for (QueryDataBatch b : results) {
if (b.getHeader().getRowCount() == 0) {
continue;
}
batchCount++;
RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
loader.load(b.getHeader().getDef(), b.getData());
BigIntVector c1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
BigIntVector.Accessor a1 = c1.getAccessor();
for (int i = 0; i < c1.getAccessor().getValueCount(); i++) {
recordCount++;
assertTrue(previousBigInt <= a1.get(i));
previousBigInt = a1.get(i);
}
loader.clear();
b.release();
}
System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount));
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestBroadcastExchange method TestSingleBroadcastExchangeWithTwoScans.
@Test
public void TestSingleBroadcastExchangeWithTwoScans() throws Exception {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit1.run();
bit2.run();
client.connect();
String physicalPlan = Files.toString(DrillFileUtils.getResourceAsFile("/sender/broadcast_exchange.json"), Charsets.UTF_8).replace("#{LEFT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.left.json").toURI().toString()).replace("#{RIGHT_FILE}", DrillFileUtils.getResourceAsFile("/join/merge_single_batch.right.json").toURI().toString());
List<QueryDataBatch> results = client.runQuery(QueryType.PHYSICAL, physicalPlan);
int count = 0;
for (QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(25, count);
}
}
Aggregations