Search in sources :

Example 51 with DrillClient

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

the class TestMergeJoinMulCondition method testMergeJoinInnerNullKey.

@Test
public // select * from cp.`region.json` t1, cp.`region.json` t2 where t1.non_exist = t2.non_exist2 ;
void testMergeJoinInnerNullKey() 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}", "INNER"));
        int count = 0;
        for (QueryDataBatch b : results) {
            if (b.getHeader().getRowCount() != 0) {
                count += b.getHeader().getRowCount();
            }
            b.release();
        }
        assertEquals(0, 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 52 with DrillClient

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

the class TestMergeJoinMulCondition method testMergeJoinMultiKeys.

@Test
public //      + "    l.l_suppkey = ps.ps_suppkey";
void testMergeJoinMultiKeys() 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/mj_multi_condition.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            if (b.getHeader().getRowCount() != 0) {
                count += b.getHeader().getRowCount();
            }
            b.release();
        }
        assertEquals(60175, 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 53 with DrillClient

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

the class TestDateTypes method testTimeStamp.

@Test
public void testTimeStamp() 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("/record/vector/test_timestamp.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/test_simple_date.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).toString(), "1970-01-02 10:20:33.000");
            assertEquals(accessor.getObject(1).toString(), "2008-12-28 11:34:00.129");
            assertEquals(accessor.getObject(2).toString(), "2000-02-27 14:24:00.000");
        }
        batchLoader.clear();
        for (QueryDataBatch b : results) {
            b.release();
        }
    }
}
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 54 with DrillClient

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

the class TestDateTypes method testInterval.

@Test
public void testInterval() 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("/record/vector/test_interval.json"), Charsets.UTF_8).replace("#{TEST_FILE}", "/test_simple_interval.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();
        ValueVector.Accessor accessor = itr.next().getValueVector().getAccessor();
        // Check the interval type
        assertEquals((accessor.getObject(0).toString()), ("2 years 2 months 1 day 1:20:35.0"));
        assertEquals((accessor.getObject(1).toString()), ("2 years 2 months 0 days 0:0:0.0"));
        assertEquals((accessor.getObject(2).toString()), ("0 years 0 months 0 days 1:20:35.0"));
        assertEquals((accessor.getObject(3).toString()), ("2 years 2 months 1 day 1:20:35.897"));
        assertEquals((accessor.getObject(4).toString()), ("0 years 0 months 0 days 0:0:35.4"));
        assertEquals((accessor.getObject(5).toString()), ("1 year 10 months 1 day 0:-39:-25.0"));
        accessor = itr.next().getValueVector().getAccessor();
        // Check the interval year type
        assertEquals((accessor.getObject(0).toString()), ("2 years 2 months "));
        assertEquals((accessor.getObject(1).toString()), ("2 years 2 months "));
        assertEquals((accessor.getObject(2).toString()), ("0 years 0 months "));
        assertEquals((accessor.getObject(3).toString()), ("2 years 2 months "));
        assertEquals((accessor.getObject(4).toString()), ("0 years 0 months "));
        assertEquals((accessor.getObject(5).toString()), ("1 year 10 months "));
        accessor = itr.next().getValueVector().getAccessor();
        // Check the interval day type
        assertEquals((accessor.getObject(0).toString()), ("1 day 1:20:35.0"));
        assertEquals((accessor.getObject(1).toString()), ("0 days 0:0:0.0"));
        assertEquals((accessor.getObject(2).toString()), ("0 days 1:20:35.0"));
        assertEquals((accessor.getObject(3).toString()), ("1 day 1:20:35.897"));
        assertEquals((accessor.getObject(4).toString()), ("0 days 0:0:35.4"));
        assertEquals((accessor.getObject(5).toString()), ("1 day 0:-39:-25.0"));
        batchLoader.clear();
        for (QueryDataBatch b : results) {
            b.release();
        }
    }
}
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) VectorWrapper(org.apache.drill.exec.record.VectorWrapper) DrillClient(org.apache.drill.exec.client.DrillClient) Test(org.junit.Test)

Example 55 with DrillClient

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

the class TestDistributedFragmentRun method oneBitOneExchangeTwoEntryRun.

@Test
public void oneBitOneExchangeTwoEntryRun() 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_double_entry.json"), Charsets.UTF_8));
        int count = 0;
        for (QueryDataBatch b : results) {
            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