mayankshriv commented on a change in pull request #4877: Results in ResultTable
if responseFormat=sql
URL: https://github.com/apache/incubator-pinot/pull/4877#discussion_r353459986
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/AggregationDataTableReducer.java
##########
@@ -41,33 +45,46 @@
public class AggregationDataTableReducer implements DataTableReducer {
private final AggregationFunction[] _aggregationFunctions;
+ private final List<AggregationInfo> _aggregationInfos;
+ private final int _numAggregationFunctions;
private final boolean _preserveType;
+ private boolean _responseFormatSql;
AggregationDataTableReducer(BrokerRequest brokerRequest,
AggregationFunction[] aggregationFunctions,
QueryOptions queryOptions) {
_aggregationFunctions = aggregationFunctions;
+ _aggregationInfos = brokerRequest.getAggregationsInfo();
+ _numAggregationFunctions = aggregationFunctions.length;
_preserveType = queryOptions.isPreserveType();
+ _responseFormatSql = queryOptions.isResponseFormatSQL();
}
/**
- * Reduces data tables and sets aggregations results into
BrokerResponseNative::AggregationResults
+ * Reduces data tables and sets aggregations results into
+ * 1. ResultTable if _responseFormatSql is true
+ * 2. AggregationResults by default
*/
@Override
- public void reduceAndSetResults(String tableName, DataSchema dataSchema,
Map<ServerRoutingInstance, DataTable> dataTableMap,
- BrokerResponseNative brokerResponseNative, BrokerMetrics brokerMetrics) {
+ public void reduceAndSetResults(String tableName, DataSchema dataSchema,
+ Map<ServerRoutingInstance, DataTable> dataTableMap, BrokerResponseNative
brokerResponseNative,
+ BrokerMetrics brokerMetrics) {
+
if (dataTableMap.isEmpty()) {
+ if (_responseFormatSql) {
Review comment:
Any way to avoid this `if` check in various places? I guess the issue is
that we are setting different fields in BrokerResponse, or else, we could have
just used an interface over ResultTable and the old format?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]