use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestHashJoin method simpleEqualityJoin.
@Test
public void simpleEqualityJoin() throws Throwable {
// Function checks hash join with single equality condition
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("/join/hash_join.json"), Charsets.UTF_8).replace("#{TEST_FILE_1}", DrillFileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()).replace("#{TEST_FILE_2}", DrillFileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString()));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
QueryDataBatch batch = results.get(1);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
// Just test the join key
long[] colA = { 1, 1, 2, 2, 1, 1 };
// Check the output of decimal9
ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor();
for (int i = 0; i < intAccessor1.getValueCount(); i++) {
assertEquals(intAccessor1.getObject(i), colA[i]);
}
assertEquals(6, intAccessor1.getValueCount());
batchLoader.clear();
for (QueryDataBatch result : results) {
result.release();
}
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestHashJoin method testHashJoinExprInCondition.
@Test
public void testHashJoinExprInCondition() 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, Files.toString(DrillFileUtils.getResourceAsFile("/join/hashJoinExpr.json"), Charsets.UTF_8));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(10, count);
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestHashJoin method hjWithExchange.
@Test
public void hjWithExchange() throws Throwable {
// Function tests with hash join with exchanges
try (final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
final Drillbit bit = new Drillbit(CONFIG, serviceSet);
final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
// run query.
bit.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/join/hj_exchanges.json"), Charsets.UTF_8));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
System.out.println("Total records: " + count);
assertEquals(25, count);
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestMergeJoin method testMergeJoinExprInCondition.
@Test
public void testMergeJoinExprInCondition() 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, Files.toString(DrillFileUtils.getResourceAsFile("/join/mergeJoinExpr.json"), Charsets.UTF_8));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(10, count);
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by axbaretto.
the class TestMergeJoin method testMergeJoinRightEmptyBatch.
@Test
public void testMergeJoinRightEmptyBatch() 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, Files.toString(DrillFileUtils.getResourceAsFile("/join/merge_join_empty_batch.json"), Charsets.UTF_8).replace("${JOIN_TYPE}", "RIGHT"));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(0, count);
}
}
Aggregations