Search in sources :

Example 51 with ServerInstance

use of com.linkedin.pinot.common.response.ServerInstance in project pinot by linkedin.

the class QueryExceptionTest method testQueryPlanFailedQuery.

@Test
public void testQueryPlanFailedQuery() throws Exception {
    String query = "select sum(blablaa) from testTable where column1='24516187'";
    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.assertTrue(brokerResponse.getExceptionsSize() > 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 52 with ServerInstance

use of com.linkedin.pinot.common.response.ServerInstance in project pinot by linkedin.

the class QueryExceptionTest method testSingleQuery.

@Test
public void testSingleQuery() throws Exception {
    String query = "select count(*) from testTable where column1='24516187'";
    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 53 with ServerInstance

use of com.linkedin.pinot.common.response.ServerInstance in project pinot by linkedin.

the class QueryExceptionTest method testQueryParsingFailedQuery.

@Test
public void testQueryParsingFailedQuery() throws Exception {
    String query = "select sudm(blablaa) from testTable where column1='24516187'";
    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.assertTrue(brokerResponse.getExceptionsSize() > 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 54 with ServerInstance

use of com.linkedin.pinot.common.response.ServerInstance in project pinot by linkedin.

the class RealtimeQueriesSentinelTest method test1.

@Test
public void test1() throws Exception {
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    String query = "select sum('count') from testTable where column13='1540094560' group by column3 top 100 limit 0";
    Map<Object, Double> fromAvro = new HashMap<Object, Double>();
    fromAvro.put(null, 2.0D);
    fromAvro.put("", 1.2469280068E10D);
    fromAvro.put("F", 127.0D);
    fromAvro.put("A", 20.0D);
    fromAvro.put("H", 29.0D);
    final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(query);
    InstanceRequest instanceRequest = new InstanceRequest(485, 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);
    BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
    JSONArray actual = brokerResponse.toJson().getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult");
    assertGroupByResults(actual, fromAvro);
}
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) 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 55 with ServerInstance

use of com.linkedin.pinot.common.response.ServerInstance 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

ServerInstance (com.linkedin.pinot.common.response.ServerInstance)55 HashMap (java.util.HashMap)35 Test (org.testng.annotations.Test)35 DataTable (com.linkedin.pinot.common.utils.DataTable)26 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)23 BrokerResponseNative (com.linkedin.pinot.common.response.broker.BrokerResponseNative)23 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)22 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)22 ArrayList (java.util.ArrayList)18 SegmentIdSet (com.linkedin.pinot.transport.common.SegmentIdSet)14 ByteBuf (io.netty.buffer.ByteBuf)11 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)10 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)10 HashedWheelTimer (io.netty.util.HashedWheelTimer)10 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)9 QuerySource (com.linkedin.pinot.common.request.QuerySource)8 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)8 SegmentId (com.linkedin.pinot.transport.common.SegmentId)8 EventLoopGroup (io.netty.channel.EventLoopGroup)8 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)8