fx19880617 commented on a change in pull request #5033: Set alias name in resultTable schema
names
URL: https://github.com/apache/incubator-pinot/pull/5033#discussion_r374402217
##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java
##########
@@ -178,7 +188,46 @@ public BrokerResponseNative reduceOnDataTable(BrokerRequest brokerRequest,
}
DataTableReducer dataTableReducer = ResultReducerFactory.getResultReducer(brokerRequest);
- dataTableReducer.reduceAndSetResults(tableName, cachedDataSchema, dataTableMap, brokerResponseNative,
brokerMetrics);
+ dataTableReducer
+ .reduceAndSetResults(tableName, cachedDataSchema, dataTableMap, brokerResponseNative,
brokerMetrics);
+ updateAliasToSchemaName(brokerRequest, brokerResponseNative);
return brokerResponseNative;
}
-}
+
+ private static void updateAliasToSchemaName(BrokerRequest brokerRequest, BrokerResponseNative
brokerResponseNative) {
+ if (brokerRequest.getPinotQuery() == null) {
+ return;
+ }
+ QueryOptions queryOptions = new QueryOptions(brokerRequest.getQueryOptions());
+ if (!queryOptions.isResponseFormatSQL()) {
+ return;
+ }
+ DataSchema dataSchema = brokerResponseNative.getResultTable().getDataSchema();
+ List<Expression> selectList = brokerRequest.getPinotQuery().getSelectList();
+ String[] columnNames = dataSchema.getColumnNames();
+ int selectListSize = selectList.size();
+ if (columnNames.length != selectListSize) {
+ return;
+ }
+ for (int i = 0; i < selectListSize; i++) {
+ Function selectFunc = selectList.get(i).getFunctionCall();
+ if (selectFunc != null && selectFunc.getOperator()
+ .equalsIgnoreCase(SqlKind.AS.toString())) {
+ String aliasName = null;
Review comment:
make sense, will update the query parsing logic there.
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
|