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;
}
}
}
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);
}
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);
}
}
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);
}
Aggregations