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 18:21:04 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_r374259502
 
 

 ##########
 File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java
 ##########
 @@ -178,7 +185,45 @@ 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();
+    if (columnNames.length != selectList.size()) {
+      LOGGER.error("Response schema size {} is different from number of selection expressions
{}", columnNames.length,
+          selectList.size());
+      return;
+    }
+    for (int i = 0; i < selectList.size(); i++) {
+      if (selectList.get(i).getFunctionCall() != null && selectList.get(i).getFunctionCall().getOperator()
 
 Review comment:
   Cache `selectList.get(i).getFunctionCall()`, same for other places

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