Search in sources :

Example 1 with DrillClient

use of org.apache.drill.exec.client.DrillClient in project drill by apache.

the class TestCastVarCharToBigInt method testCastToBigInt.

//    private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestCastVarCharToBigInt.class);
@Test
public void testCastToBigInt() 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(FileUtils.getResourceAsFile("/functions/cast/test_cast_varchar_to_bigint.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/scan_json_test_cast.json"));
        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();
            assertEquals(accessor.getObject(0), 2008L);
            assertEquals(accessor.getObject(1), 2007L);
            assertEquals(accessor.getObject(2), 2006L);
        }
        for (QueryDataBatch b : results) {
            b.release();
        }
        batchLoader.clear();
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 2 with DrillClient

use of org.apache.drill.exec.client.DrillClient 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.toString(FileUtils.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();
        }
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 3 with DrillClient

use of org.apache.drill.exec.client.DrillClient in project drill by apache.

the class TestDistributedFragmentRun method oneBitOneExchangeOneEntryRun.

@Test
public void oneBitOneExchangeOneEntryRun() 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(QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/physical_single_exchange.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            count += b.getHeader().getRowCount();
            b.release();
        }
        assertEquals(100, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 4 with DrillClient

use of org.apache.drill.exec.client.DrillClient in project drill by apache.

the class TestDistributedFragmentRun method oneBitOneExchangeTwoEntryRunLogical.

@Test
public void oneBitOneExchangeTwoEntryRunLogical() 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(QueryType.LOGICAL, Files.toString(FileUtils.getResourceAsFile("/scan_screen_logical.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            count += b.getHeader().getRowCount();
            b.release();
        }
        assertEquals(100, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 5 with DrillClient

use of org.apache.drill.exec.client.DrillClient in project drill by apache.

the class TestHashToRandomExchange method twoBitTwoExchangeTwoEntryRun.

@Test
public void twoBitTwoExchangeTwoEntryRun() 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();
        List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/sender/hash_exchange.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            if (b.getHeader().getRowCount() != 0) {
                count += b.getHeader().getRowCount();
            }
            b.release();
        }
        assertEquals(200, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Aggregations

DrillClient (org.apache.drill.exec.client.DrillClient)61 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)57 Drillbit (org.apache.drill.exec.server.Drillbit)55 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)55 Test (org.junit.Test)53 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)37 ValueVector (org.apache.drill.exec.vector.ValueVector)28 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)13 ExecTest (org.apache.drill.exec.ExecTest)8 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)6 DrillConfig (org.apache.drill.common.config.DrillConfig)4 VarBinaryHolder (org.apache.drill.exec.expr.holders.VarBinaryHolder)3 QueryData (org.apache.drill.exec.proto.UserBitShared.QueryData)3 VarBinaryVector (org.apache.drill.exec.vector.VarBinaryVector)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 BigIntVector (org.apache.drill.exec.vector.BigIntVector)2 Ignore (org.junit.Ignore)2 Stopwatch (com.google.common.base.Stopwatch)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1