use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
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.asCharSource(DrillFileUtils.getResourceAsFile("/join/hashJoinExpr.json"), Charsets.UTF_8).read());
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 apache.
the class TestHashJoin method multipleConditionJoin.
@Test
public void multipleConditionJoin() throws Throwable {
// Function tests hash join with multiple join conditions
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.asCharSource(DrillFileUtils.getResourceAsFile("/join/hj_multi_condition_join.json"), Charsets.UTF_8).read().replace("#{TEST_FILE_1}", DrillFileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()).replace("#{TEST_FILE_2}", DrillFileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString()));
final RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
final QueryDataBatch batch = results.get(1);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
final Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
// Just test the join key
final long[] colA = { 1, 2, 1 };
final long[] colC = { 100, 200, 500 };
// Check the output of decimal9
final ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor();
final ValueVector.Accessor intAccessor2 = itr.next().getValueVector().getAccessor();
for (int i = 0; i < intAccessor1.getValueCount(); i++) {
assertEquals(intAccessor1.getObject(i), colA[i]);
assertEquals(intAccessor2.getObject(i), colC[i]);
}
assertEquals(3, intAccessor1.getValueCount());
batchLoader.clear();
for (final QueryDataBatch result : results) {
result.release();
}
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestMergeJoin method testMergeJoinLeftEmptyBatch.
@Test
public void testMergeJoinLeftEmptyBatch() 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.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_join_empty_batch.json"), Charsets.UTF_8).read().replace("${JOIN_TYPE}", "LEFT"));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(50, count);
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestMergeJoinMulCondition method testMergeJoinLeftOuterNullKey.
@Test
public // select * from cp.`region.json` t1 left outer join cp.`region.json` t2 on t1.non_exist = t2.non_exist2 ;
void testMergeJoinLeftOuterNullKey() throws Exception {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.asCharSource(DrillFileUtils.getResourceAsFile("/join/merge_join_nullkey.json"), Charsets.UTF_8).read().replace("${JOIN_TYPE}", "LEFT"));
int count = 0;
for (QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(110, count);
}
}
use of org.apache.drill.exec.rpc.user.QueryDataBatch in project drill by apache.
the class TestCTAS method testPartitionByForAllTypes.
@Test
public void testPartitionByForAllTypes() throws Exception {
final String location = "partitioned_tables_with_nulls";
final String ctasQuery = "create table %s partition by (%s) as %s";
final String tablePath = "dfs.tmp.`%s/%s_%s`";
// key - new table suffix, value - data query
final Map<String, String> variations = Maps.newHashMap();
variations.put("required", "select * from cp.`parquet/alltypes_required.parquet`");
variations.put("optional", "select * from cp.`parquet/alltypes_optional.parquet`");
variations.put("nulls_only", "select * from cp.`parquet/alltypes_optional.parquet` where %s is null");
final QueryDataBatch result = testSqlWithResults("select * from cp.`parquet/alltypes_required.parquet` limit 0").get(0);
for (UserBitShared.SerializedField field : result.getHeader().getDef().getFieldList()) {
final String fieldName = field.getNamePart().getName();
for (Map.Entry<String, String> variation : variations.entrySet()) {
final String table = String.format(tablePath, location, fieldName, variation.getKey());
final String dataQuery = String.format(variation.getValue(), fieldName);
test(ctasQuery, table, fieldName, dataQuery, fieldName);
testBuilder().sqlQuery("select * from %s", table).unOrdered().sqlBaselineQuery(dataQuery).build().run();
}
}
result.release();
}
Aggregations