Search in sources :

Example 1 with TestGroupByAggreationQuery

use of com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery in project pinot by linkedin.

the class RealtimeQueriesSentinelTest method testAggregationGroupBy.

@Test
public void testAggregationGroupBy() throws Exception {
    final List<TestGroupByAggreationQuery> groupByCalls = AVRO_QUERY_GENERATOR.giveMeNGroupByAggregationQueries(10000);
    int counter = 0;
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    for (final TestGroupByAggreationQuery groupBy : groupByCalls) {
        LOGGER.info("running " + counter + " : " + groupBy.pql);
        final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(groupBy.pql);
        InstanceRequest instanceRequest = new InstanceRequest(counter++, brokerRequest);
        instanceRequest.setSearchSegments(new ArrayList<String>());
        instanceRequest.getSearchSegments().add("testTable_testTable");
        QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
        DataTable instanceResponse = QUERY_EXECUTOR.processQuery(queryRequest, queryRunners);
        instanceResponseMap.clear();
        instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse);
        Map<Object, Double> expected = groupBy.groupResults;
        LOGGER.info("Result from avro is : " + expected);
        BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
        JSONArray actual = brokerResponse.toJson().getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult");
        try {
            assertGroupByResults(actual, expected);
        } catch (AssertionError e) {
            System.out.println("***************************************");
            System.out.println("query : " + groupBy.pql);
            System.out.println("actual : " + actual.toString(1));
            System.out.println("expected : " + groupBy.groupResults);
            System.out.println("***************************************");
            throw e;
        }
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) JSONArray(org.json.JSONArray) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) TestGroupByAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Example 2 with TestGroupByAggreationQuery

use of com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery in project pinot by linkedin.

the class QueriesSentinelTest method testPercentileGroupBy.

@Test
public void testPercentileGroupBy() throws Exception {
    final List<TestGroupByAggreationQuery> groupByCalls = new ArrayList<TestGroupByAggreationQuery>();
    final int top = 1000;
    for (int i = 2; i <= 2; i++) {
        if (i == 2) {
        //continue;
        }
        groupByCalls.add(new TestGroupByAggreationQuery("select percentile50(column1) from testTable group by column" + i + " top " + top + " limit 0", null));
        groupByCalls.add(new TestGroupByAggreationQuery("select percentileest50(column1) from testTable group by column" + i + " top " + top + " limit 0", null));
    }
    ApproximateQueryTestUtil.runApproximationQueries(QUERY_EXECUTOR, segmentName, groupByCalls, TestUtils.digestEstimationThreshold, serverMetrics);
}
Also used : ArrayList(java.util.ArrayList) TestGroupByAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery) Test(org.testng.annotations.Test)

Example 3 with TestGroupByAggreationQuery

use of com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery in project pinot by linkedin.

the class QueriesSentinelTest method testAggregationGroupBy.

@Test
public void testAggregationGroupBy() throws Exception {
    final List<TestGroupByAggreationQuery> groupByCalls = AVRO_QUERY_GENERATOR.giveMeNGroupByAggregationQueries(10000);
    int counter = 0;
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    for (final TestGroupByAggreationQuery groupBy : groupByCalls) {
        LOGGER.info("running " + counter + " : " + groupBy.pql);
        final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(groupBy.pql);
        InstanceRequest instanceRequest = new InstanceRequest(counter++, brokerRequest);
        instanceRequest.setSearchSegments(new ArrayList<String>());
        instanceRequest.getSearchSegments().add(segmentName);
        QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
        final DataTable instanceResponse = QUERY_EXECUTOR.processQuery(queryRequest, queryRunners);
        instanceResponseMap.clear();
        instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse);
        final BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
        LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(0));
        LOGGER.info("Result from avro is : " + groupBy.groupResults);
        assertGroupByResults(brokerResponse.getAggregationResults().get(0).getGroupByResult(), groupBy.groupResults);
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) TestGroupByAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test)

Example 4 with TestGroupByAggreationQuery

use of com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery in project pinot by linkedin.

the class QueriesSentinelTest method testDistinctCountHLLGroupBy.

@Test
public void testDistinctCountHLLGroupBy() throws Exception {
    final List<TestGroupByAggreationQuery> groupByCalls = new ArrayList<TestGroupByAggreationQuery>();
    for (int i = 1; i <= 5; i++) {
        if (i == 2) {
            continue;
        }
        groupByCalls.add(new TestGroupByAggreationQuery("select distinctcount(column2) from testTable group by column" + i + " limit 0", null));
        groupByCalls.add(new TestGroupByAggreationQuery("select distinctcounthll(column2) from testTable group by column" + i + " limit 0", null));
    }
    ApproximateQueryTestUtil.runApproximationQueries(QUERY_EXECUTOR, segmentName, groupByCalls, TestUtils.hllEstimationThreshold, serverMetrics);
}
Also used : ArrayList(java.util.ArrayList) TestGroupByAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery) Test(org.testng.annotations.Test)

Aggregations

TestGroupByAggreationQuery (com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery)4 Test (org.testng.annotations.Test)4 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)2 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)2 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)2 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)2 BrokerResponseNative (com.linkedin.pinot.common.response.broker.BrokerResponseNative)2 DataTable (com.linkedin.pinot.common.utils.DataTable)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)1 JSONArray (org.json.JSONArray)1