Search in sources :

Example 26 with DrillClient

use of org.apache.drill.exec.client.DrillClient 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.toString(FileUtils.getResourceAsFile("/join/merge_join_nullkey.json"), Charsets.UTF_8).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);
    }
}
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 27 with DrillClient

use of org.apache.drill.exec.client.DrillClient 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.toString(FileUtils.getResourceAsFile("/work/batch/multiple_exchange.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            if (b.getHeader().getRowCount() != 0) {
                count += b.getHeader().getRowCount();
            }
            b.release();
        }
        assertEquals(500024, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) DrillConfig(org.apache.drill.common.config.DrillConfig) 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) ExecTest(org.apache.drill.exec.ExecTest)

Example 28 with DrillClient

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

the class TestParquetPhysicalPlan method testParseParquetPhysicalPlan.

@Test
@Ignore
public void testParseParquetPhysicalPlan() throws Exception {
    RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    DrillConfig config = DrillConfig.create();
    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, Resources.toString(Resources.getResource(fileName), Charsets.UTF_8));
        RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
        int count = 0;
        for (QueryDataBatch b : results) {
            System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
            count += b.getHeader().getRowCount();
            loader.load(b.getHeader().getDef(), b.getData());
            for (VectorWrapper vw : loader) {
                System.out.print(vw.getValueVector().getField().getPath() + ": ");
                ValueVector vv = vw.getValueVector();
                for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
                    Object o = vv.getAccessor().getObject(i);
                    if (o instanceof byte[]) {
                        System.out.print(" [" + new String((byte[]) o) + "]");
                    } else {
                        System.out.print(" [" + vv.getAccessor().getObject(i) + "]");
                    }
                //            break;
                }
                System.out.println();
            }
            loader.clear();
            b.release();
        }
        client.close();
        System.out.println(String.format("Got %d total results", count));
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) DrillConfig(org.apache.drill.common.config.DrillConfig) Drillbit(org.apache.drill.exec.server.Drillbit) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) VectorWrapper(org.apache.drill.exec.record.VectorWrapper) DrillClient(org.apache.drill.exec.client.DrillClient) Ignore(org.junit.Ignore) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest)

Example 29 with DrillClient

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

the class TestParquetPhysicalPlan method testParseParquetPhysicalPlanRemote.

@Test
@Ignore
public void testParseParquetPhysicalPlanRemote() throws Exception {
    DrillConfig config = DrillConfig.create();
    try (DrillClient client = new DrillClient(config)) {
        client.connect();
        ParquetResultsListener listener = new ParquetResultsListener();
        Stopwatch watch = Stopwatch.createStarted();
        client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Resources.toString(Resources.getResource(fileName), Charsets.UTF_8), listener);
        System.out.println(String.format("Got %d total records in %d seconds", listener.await(), watch.elapsed(TimeUnit.SECONDS)));
        client.close();
    }
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) Stopwatch(com.google.common.base.Stopwatch) DrillClient(org.apache.drill.exec.client.DrillClient) Ignore(org.junit.Ignore) Test(org.junit.Test) ExecTest(org.apache.drill.exec.ExecTest)

Example 30 with DrillClient

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

the class TestHBaseCFAsJSONString method openMyClient.

@BeforeClass
public static void openMyClient() throws Exception {
    parent_client = client;
    client = new DrillClient(config, serviceSet.getCoordinator());
    client.setSupportComplexTypes(false);
    client.connect();
}
Also used : DrillClient(org.apache.drill.exec.client.DrillClient) BeforeClass(org.junit.BeforeClass)

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