use of com.linkedin.pinot.common.utils.DataTable in project pinot by linkedin.
the class IntermediateResultsBlock method getAggregationGroupByResultDataTable.
@Nonnull
private DataTable getAggregationGroupByResultDataTable() throws Exception {
String[] columnNames = new String[] { "functionName", "GroupByResultMap" };
FieldSpec.DataType[] columnTypes = new FieldSpec.DataType[] { FieldSpec.DataType.STRING, FieldSpec.DataType.OBJECT };
// Build the data table.
DataTableBuilder dataTableBuilder = new DataTableBuilder(new DataSchema(columnNames, columnTypes));
int numAggregationFunctions = _aggregationFunctionContexts.length;
for (int i = 0; i < numAggregationFunctions; i++) {
dataTableBuilder.startRow();
AggregationFunctionContext aggregationFunctionContext = _aggregationFunctionContexts[i];
dataTableBuilder.setColumn(0, aggregationFunctionContext.getAggregationColumnName());
dataTableBuilder.setColumn(1, _combinedAggregationGroupByResult.get(i));
dataTableBuilder.finishRow();
}
DataTable dataTable = dataTableBuilder.build();
return attachMetadataToDataTable(dataTable);
}
use of com.linkedin.pinot.common.utils.DataTable in project pinot by linkedin.
the class QueriesSentinelTest method testTrace.
@Test
public void testTrace() throws Exception {
String query = "select count(*) from testTable where column1='186154188'";
LOGGER.info("running : " + query);
final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(query);
//
brokerRequest.setEnableTrace(true);
InstanceRequest instanceRequest = new InstanceRequest(1, brokerRequest);
// TODO: add trace settings consistency
instanceRequest.setEnableTrace(true);
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("TraceInfo is " + brokerResponse.getTraceInfo());
}
use of com.linkedin.pinot.common.utils.DataTable 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.utils.DataTable 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);
}
use of com.linkedin.pinot.common.utils.DataTable 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));
}
Aggregations