pinot-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5033: Set alias name in resultTable schema names
Date Mon, 03 Feb 2020 23:24:25 GMT
Jackie-Jiang 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_r374398649
 
 

 ##########
 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:
   We should not perform sanity check here, but when we compile the query. At this point,
alias should always exist and should always be identifier.

----------------------------------------------------------------
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


Mime
View raw message