Search in sources :

Example 1 with TestSimpleAggreationQuery

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

the class QueriesSentinelTest method testDistinctCountHLLNoGroupBy.

/**
   * Console output of the last statement may not appear, maybe a result of intellij idea test console redirection.
   * To avoid this, always add assert clauses, and do not rely on the console output.
   *
   * @throws Exception
   */
@Test
public void testDistinctCountHLLNoGroupBy() throws Exception {
    final List<TestSimpleAggreationQuery> aggCalls = new ArrayList<TestSimpleAggreationQuery>();
    // distinct count(*) not works
    for (int i = 1; i <= 5; i++) {
        aggCalls.add(new TestSimpleAggreationQuery("select distinctcount(column" + i + ") from testTable limit 0", 0.0));
        aggCalls.add(new TestSimpleAggreationQuery("select distinctcounthll(column" + i + ") from testTable limit 0", 0.0));
    }
    ApproximateQueryTestUtil.runApproximationQueries(QUERY_EXECUTOR, segmentName, aggCalls, TestUtils.hllEstimationThreshold, serverMetrics);
}
Also used : ArrayList(java.util.ArrayList) TestSimpleAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery) Test(org.testng.annotations.Test)

Example 2 with TestSimpleAggreationQuery

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

the class QueriesSentinelTest method testPercentileNoGroupBy.

@Test
public void testPercentileNoGroupBy() throws Exception {
    final List<TestSimpleAggreationQuery> aggCalls = new ArrayList<TestSimpleAggreationQuery>();
    // 5 single-value columns -- column 3 is String type
    for (int i = 1; i <= 2; i++) {
        aggCalls.add(new TestSimpleAggreationQuery("select percentile50(column" + i + ") from testTable limit 0", 0.0));
        aggCalls.add(new TestSimpleAggreationQuery("select percentileest50(column" + i + ") from testTable limit 0", 0.0));
    }
    ApproximateQueryTestUtil.runApproximationQueries(QUERY_EXECUTOR, segmentName, aggCalls, TestUtils.digestEstimationThreshold, serverMetrics);
}
Also used : ArrayList(java.util.ArrayList) TestSimpleAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery) Test(org.testng.annotations.Test)

Example 3 with TestSimpleAggreationQuery

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

the class QueriesSentinelTest method testAggregation.

@Test
public void testAggregation() throws Exception {
    int counter = 0;
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    final List<TestSimpleAggreationQuery> aggCalls = AVRO_QUERY_GENERATOR.giveMeNSimpleAggregationQueries(10000);
    for (final TestSimpleAggreationQuery aggCall : aggCalls) {
        LOGGER.info("running " + counter + " : " + aggCall.pql);
        final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(aggCall.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 : " + aggCall.result);
        Assert.assertEquals(Double.parseDouble(brokerResponse.getAggregationResults().get(0).getValue().toString()), aggCall.result);
    }
}
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) TestSimpleAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test)

Example 4 with TestSimpleAggreationQuery

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

the class HllIndexSentinelTest method testFastHllNoGroupBy.

@Test
public void testFastHllNoGroupBy() throws Exception {
    final int baseValue = 10000000;
    final String[] filterColumns = { "column1", /* first split */
    "column17" };
    for (String filterColumn : filterColumns) {
        for (String distinctCountColumn : columnsToDeriveHllFields) {
            final List<TestSimpleAggreationQuery> aggCalls = new ArrayList<>();
            aggCalls.add(new TestSimpleAggreationQuery("select fasthll(" + distinctCountColumn + ") from " + tableName + " where " + filterColumn + " > " + baseValue + " limit 0", 0.0));
            aggCalls.add(new TestSimpleAggreationQuery("select distinctcounthll(" + distinctCountColumn + ") from " + tableName + " where " + filterColumn + " > " + baseValue + " limit 0", 0.0));
            ApproximateQueryTestUtil.runApproximationQueries(testHelper.queryExecutor, segmentName, aggCalls, approximationThreshold, testHelper.serverMetrics);
            // correct query
            Object ret = ApproximateQueryTestUtil.runQuery(testHelper.queryExecutor, segmentName, new TestSimpleAggreationQuery("select distinctcount(" + distinctCountColumn + ") from " + tableName + " where " + filterColumn + " > " + baseValue + " limit 0", 0.0), testHelper.serverMetrics);
            LOGGER.debug(ret.toString());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) TestSimpleAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery) Test(org.testng.annotations.Test)

Example 5 with TestSimpleAggreationQuery

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

the class RealtimeQueriesSentinelTest method testAggregation.

@Test
public void testAggregation() throws Exception {
    int counter = 0;
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    final List<TestSimpleAggreationQuery> aggCalls = AVRO_QUERY_GENERATOR.giveMeNSimpleAggregationQueries(10000);
    for (final TestSimpleAggreationQuery aggCall : aggCalls) {
        LOGGER.info("running " + counter + " : " + aggCall.pql);
        final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(aggCall.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);
        final BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
        LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(0));
        LOGGER.info("Result from avro is : " + aggCall.result);
        Double actual = Double.parseDouble(brokerResponse.getAggregationResults().get(0).getValue().toString());
        Double expected = aggCall.result;
        try {
            Assert.assertEquals(actual, expected);
        } catch (AssertionError e) {
            System.out.println("********************************");
            System.out.println("query : " + aggCall.pql);
            System.out.println("actual : " + actual);
            System.out.println("expected : " + aggCall.result);
            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) TestSimpleAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) 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)

Aggregations

TestSimpleAggreationQuery (com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery)5 Test (org.testng.annotations.Test)5 ArrayList (java.util.ArrayList)3 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 HashMap (java.util.HashMap)2 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)1