use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
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.asCharSource(DrillFileUtils.getResourceAsFile("/functions/cast/testCastVarCharNull.json"), Charsets.UTF_8).read().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 apache.
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.asCharSource(DrillFileUtils.getResourceAsFile("/functions/multi_input_add_test.json"), Charsets.UTF_8).read());
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.server.RemoteServiceSet in project drill by apache.
the class TestNewAggregateFunctions method runTest.
public void runTest(String physicalPlan, String inputDataFile, Object[] expected) 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(QueryType.PHYSICAL, Files.asCharSource(DrillFileUtils.getResourceAsFile(physicalPlan), Charsets.UTF_8).read().replace("#{TEST_FILE}", inputDataFile));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
QueryDataBatch batch = results.get(1);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
int i = 0;
for (VectorWrapper<?> v : batchLoader) {
ValueVector.Accessor accessor = v.getValueVector().getAccessor();
assertEquals(expected[i++], (accessor.getObject(0)));
}
batchLoader.clear();
for (QueryDataBatch b : results) {
b.release();
}
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
the class ExpressionInterpreterTest method doTest.
protected void doTest(String expressionStr, String[] colNames, TypeProtos.MajorType[] colTypes, String[] expectFirstTwoValues, BitControl.PlanFragment planFragment) throws Exception {
final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
bit1.run();
// Create a mock scan batch as input for evaluation.
assertEquals(colNames.length, colTypes.length);
final MockTableDef.MockColumn[] columns = new MockTableDef.MockColumn[colNames.length];
for (int i = 0; i < colNames.length; i++) {
columns[i] = new MockTableDef.MockColumn(colNames[i], colTypes[i].getMinorType(), colTypes[i].getMode(), 0, 0, 0, null, null, null);
}
final MockTableDef.MockScanEntry entry = new MockTableDef.MockScanEntry(10, false, 0, 1, columns);
final MockSubScanPOP scanPOP = new MockSubScanPOP("testTable", false, java.util.Collections.singletonList(entry));
final CloseableRecordBatch batch = createMockScanBatch(bit1, scanPOP, planFragment);
batch.next();
final ValueVector vv = evalExprWithInterpreter(expressionStr, batch, bit1);
// Verify the first 2 values in the output of evaluation.
assertEquals(2, expectFirstTwoValues.length);
assertEquals(expectFirstTwoValues[0], getValueFromVector(vv, 0));
assertEquals(expectFirstTwoValues[1], getValueFromVector(vv, 1));
showValueVectorContent(vv);
vv.clear();
batch.close();
batch.getContext().close();
bit1.close();
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
the class TestSpoolingBuffer method testMultipleExchangesSingleThread.
@Test
public void testMultipleExchangesSingleThread() throws Exception {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
DrillConfig conf = DrillConfig.create("drill-spool-test-module.conf");
try (Drillbit bit1 = new Drillbit(conf, serviceSet);
DrillClient client = new DrillClient(conf, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.asCharSource(DrillFileUtils.getResourceAsFile("/work/batch/multiple_exchange.json"), Charsets.UTF_8).read());
int count = 0;
for (QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(500024, count);
}
}
Aggregations