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