Search in sources :

Example 21 with BrokerResponseNative

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

the class QueryExceptionTest method testQueryExecuteFailedQuery.

@Test
public void testQueryExecuteFailedQuery() throws Exception {
    String query = "select count(*) from testTable where column1='24516187' group by bla";
    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);
    Assert.assertEquals(brokerResponse.getExceptionsSize(), 1);
}
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 22 with BrokerResponseNative

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

the class QueriesSentinelTest method testMatchAllQuery.

@Test
public void testMatchAllQuery() throws Exception {
    String query = "select count(*),sum(count) from testTable  ";
    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);
    LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(0));
    LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(1));
    Assert.assertEquals(Double.parseDouble(brokerResponse.getAggregationResults().get(0).getValue().toString()), 100000.0);
    Assert.assertEquals(Double.parseDouble(brokerResponse.getAggregationResults().get(1).getValue().toString()), 8.90662862E13);
    Assert.assertEquals(brokerResponse.getNumDocsScanned(), 100000);
}
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 23 with BrokerResponseNative

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

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

the class InterSegmentAggregationSingleValueQueriesTest method testPercentile50.

@Test
public void testPercentile50() {
    String query = "SELECT PERCENTILE50(column1), PERCENTILE50(column3) FROM testTable";
    BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 120000L, 0L, 240000L, 120000L, new String[] { "1107310944.00000", "1080136306.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 24516L, 336536L, 49032L, 120000L, new String[] { "1139674505.00000", "505053732.00000" });
    brokerResponse = getBrokerResponseForQuery(query + GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 120000L, 0L, 360000L, 120000L, new String[] { "2146791843.00000", "2141451242.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query + GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 24516L, 336536L, 73548L, 120000L, new String[] { "2142595699.00000", "999309554.00000" });
}
Also used : BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) Test(org.testng.annotations.Test)

Example 25 with BrokerResponseNative

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

the class BrokerReduceServiceTest method testDistinctCountQuery1.

@Test
public void testDistinctCountQuery1() {
    BrokerRequest brokerRequest = getDistinctCountQuery("dim1");
    QuerySource querySource = new QuerySource();
    querySource.setTableName("midas");
    brokerRequest.setQuerySource(querySource);
    InstanceRequest instanceRequest = new InstanceRequest(0, brokerRequest);
    instanceRequest.setSearchSegments(new ArrayList<String>());
    for (IndexSegment segment : _indexSegmentList) {
        instanceRequest.addToSearchSegments(segment.getSegmentName());
    }
    Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    try {
        QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
        DataTable instanceResponse1 = _queryExecutor.processQuery(queryRequest, queryRunners);
        instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse1);
        DataTable instanceResponse2 = _queryExecutor.processQuery(queryRequest, queryRunners);
        instanceResponseMap.put(new ServerInstance("localhost:1111"), instanceResponse2);
        BrokerResponseNative brokerResponse = _reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap);
        AggregationResult aggregationResult = brokerResponse.getAggregationResults().get(0);
        LOGGER.info("BrokerResponse is " + aggregationResult);
        checkAggregationResult(aggregationResult, "distinctCount_dim1", 100.0);
        LOGGER.info("Time used for BrokerResponse is " + brokerResponse.getTimeUsedMs());
    } catch (Exception e) {
        e.printStackTrace();
        // Should never happen
        throw new RuntimeException(e.toString(), e);
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) AggregationResult(com.linkedin.pinot.common.response.broker.AggregationResult) QuerySource(com.linkedin.pinot.common.request.QuerySource) 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