use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestBroadcastExchange method TestMultipleSendLocationBroadcastExchange.
@Test
public void TestMultipleSendLocationBroadcastExchange() 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_long_run.json"), Charsets.UTF_8);
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();
}
System.out.println(count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestCastFunctions method testCastFromNullablCol.
@Test
public void testCastFromNullablCol() throws Throwable {
final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (final Drillbit bit = new Drillbit(CONFIG, serviceSet);
final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/functions/cast/testCastVarCharNull.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/jsoninput/input1.json"));
final QueryDataBatch batch = results.get(0);
final RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
batchLoader.load(batch.getHeader().getDef(), batch.getData());
final Object[][] result = getRunResult(batchLoader);
final Object[][] expected = new Object[2][2];
expected[0][0] = new String("2001");
expected[0][1] = new String("1.2");
expected[1][0] = new String("-2002");
expected[1][1] = new String("-1.2");
assertEquals(result.length, expected.length);
assertEquals(result[0].length, expected[0].length);
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[0].length; j++) {
assertEquals(String.format("Column %s at row %s have wrong result", j, i), result[i][j].toString(), expected[i][j]);
}
}
batchLoader.clear();
for (final QueryDataBatch b : results) {
b.release();
}
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestDecimal method testSimpleDecimalMathFunc.
@Test
public void testSimpleDecimalMathFunc() throws Exception {
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("/decimal/simple_decimal_math.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/input_simple_decimal.json"));
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();
// Check the output of decimal18
ValueVector.Accessor dec18Accessor = itr.next().getValueVector().getAccessor();
assertEquals(6, dec18Accessor.getValueCount());
batchLoader.clear();
for (QueryDataBatch result : results) {
result.release();
}
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestDecimal method testCastFromFloat.
@Test
public void testCastFromFloat() throws Exception {
// 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(DrillFileUtils.getResourceAsFile("/decimal/cast_float_decimal.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/input_simple_decimal.json"));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
QueryDataBatch batch = results.get(0);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
String[] decimal9Output = { "99.0000", "11.1235", "0.1000", "-0.1200", "-123.1234", "-1.0001" };
String[] decimal38Output = { "123456789.0000", "11.1235", "0.1000", "-0.1004", "-987654321.1235", "-2.0301" };
Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
// Check the output of decimal9
ValueVector.Accessor dec9Accessor = itr.next().getValueVector().getAccessor();
ValueVector.Accessor dec38Accessor = itr.next().getValueVector().getAccessor();
for (int i = 0; i < dec9Accessor.getValueCount(); i++) {
assertEquals(dec9Accessor.getObject(i).toString(), decimal9Output[i]);
assertEquals(dec38Accessor.getObject(i).toString(), decimal38Output[i]);
}
assertEquals(6, dec9Accessor.getValueCount());
assertEquals(6, dec38Accessor.getValueCount());
batchLoader.clear();
for (QueryDataBatch result : results) {
result.release();
}
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestDecimal method testSimpleDecimal.
@Test
public void testSimpleDecimal() throws Exception {
/* Function checks casting from VarChar to Decimal9, Decimal18 and vice versa
* Also tests instances where the scale might have to truncated when scale provided < input fraction
*/
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("/decimal/cast_simple_decimal.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/input_simple_decimal.json"));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
QueryDataBatch batch = results.get(0);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
String[] decimal9Output = { "99.0000", "11.1235", "0.1000", "-0.1200", "-123.1234", "-1.0001" };
String[] decimal18Output = { "123456789.000000000", "11.123456789", "0.100000000", "-0.100400000", "-987654321.123456789", "-2.030100000" };
Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
// Check the output of decimal9
ValueVector.Accessor dec9Accessor = itr.next().getValueVector().getAccessor();
ValueVector.Accessor dec18Accessor = itr.next().getValueVector().getAccessor();
for (int i = 0; i < dec9Accessor.getValueCount(); i++) {
assertEquals(dec9Accessor.getObject(i).toString(), decimal9Output[i]);
assertEquals(dec18Accessor.getObject(i).toString(), decimal18Output[i]);
}
assertEquals(6, dec9Accessor.getValueCount());
assertEquals(6, dec18Accessor.getValueCount());
batchLoader.clear();
for (QueryDataBatch result : results) {
result.release();
}
}
}
Aggregations