Search in sources :

Example 16 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class InterSegmentAggregationSingleValueQueriesTest method testSum.

@Test
public void testSum() {
    String query = "SELECT SUM(column1), SUM(column3) FROM testTable";
    BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 120000L, 0L, 240000L, 120000L, new String[] { "129268741751388.00000", "129156636756600.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 24516L, 336536L, 49032L, 120000L, new String[] { "27503790384288.00000", "12429178874916.00000" });
    brokerResponse = getBrokerResponseForQuery(query + GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 120000L, 0L, 360000L, 120000L, new String[] { "69526727335224.00000", "69225631719808.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query + GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 24516L, 336536L, 73548L, 120000L, new String[] { "19058003631876.00000", "8606725456500.00000" });
}
Also used : BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) Test(org.testng.annotations.Test)

Example 17 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class InterSegmentAggregationSingleValueQueriesTest method testPercentile99.

@Test
public void testPercentile99() {
    String query = "SELECT PERCENTILE99(column1), PERCENTILE99(column3) FROM testTable";
    BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 120000L, 0L, 240000L, 120000L, new String[] { "2139354437.00000", "2125299552.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 24516L, 336536L, 49032L, 120000L, new String[] { "2146232405.00000", "990669195.00000" });
    brokerResponse = getBrokerResponseForQuery(query + GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 120000L, 0L, 360000L, 120000L, new String[] { "2146791843.00000", "2147419555.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query + GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 24516L, 336536L, 73548L, 120000L, new String[] { "2146232405.00000", "999309554.00000" });
}
Also used : BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) Test(org.testng.annotations.Test)

Example 18 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative 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 19 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class QueriesSentinelTest method testSingleQuery.

@Test
public void testSingleQuery() throws Exception {
    String query;
    query = "select count(*) from testTable where column5='kCMyNVGCASKYDdQbftOPaqVMWc'";
    //query= "select sum('count') from testTable where column1='660156454'";
    LOGGER.info("running  : " + query);
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(query);
    InstanceRequest instanceRequest = new InstanceRequest(1, 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));
}
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) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test)

Example 20 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class QueriesSentinelTest method testRangeQuery.

@Test
public void testRangeQuery() throws Exception {
    String query = "select count(*) from testTable where column1 in ('999983251', '510705831', '1000720716', '1001058817', '1001099410')";
    LOGGER.info("running  : " + query);
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(query);
    InstanceRequest instanceRequest = new InstanceRequest(1, 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));
    Assert.assertEquals(Double.parseDouble(brokerResponse.getAggregationResults().get(0).getValue().toString()), 14.0);
    Assert.assertEquals(brokerResponse.getNumDocsScanned(), 14);
}
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) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test)

Aggregations

BrokerResponseNative (com.linkedin.pinot.common.response.broker.BrokerResponseNative)58 Test (org.testng.annotations.Test)56 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)23 DataTable (com.linkedin.pinot.common.utils.DataTable)23 HashMap (java.util.HashMap)23 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)22 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)22 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)22 QuerySource (com.linkedin.pinot.common.request.QuerySource)8 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)8 AggregationResult (com.linkedin.pinot.common.response.broker.AggregationResult)6 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)3 TestGroupByAggreationQuery (com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery)2 TestSimpleAggreationQuery (com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery)2 QueryProcessingException (com.linkedin.pinot.common.response.broker.QueryProcessingException)2 JSONArray (org.json.JSONArray)2 SelectionResults (com.linkedin.pinot.common.response.broker.SelectionResults)1 DataSchema (com.linkedin.pinot.common.utils.DataSchema)1 AggregationFunction (com.linkedin.pinot.core.query.aggregation.function.AggregationFunction)1 Serializable (java.io.Serializable)1