npawar commented on a change in pull request #4602: First pass of GROUP BY with 
ORDER BY support
URL: https://github.com/apache/incubator-pinot/pull/4602#discussion_r326759480
 
 

 ##########
 File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/BrokerReduceService.java
 ##########
 @@ -204,18 +215,25 @@ public BrokerResponseNative reduceOnDataTable(@Nonnull 
BrokerRequest brokerReque
     }
 
     // Parse the option from request whether to preserve the type
-    String preserveTypeString = (brokerRequest.getQueryOptions() == null) ? 
"false" : brokerRequest.getQueryOptions()
-        
.getOrDefault(CommonConstants.Broker.Request.QueryOptionKey.PRESERVE_TYPE, 
"false");
+    Map<String, String> queryOptions = brokerRequest.getQueryOptions();
+    String preserveTypeString =
+        (queryOptions == null) ? "false" : 
queryOptions.getOrDefault(QueryOptionKey.PRESERVE_TYPE, "false");
     boolean preserveType = Boolean.valueOf(preserveTypeString);
 
     if (dataTableMap.isEmpty()) {
-      // For empty data table map, construct empty result using the cached 
data schema.
-
-      // This will only happen to selection query.
+      // even though results empty, set columns for these operations
       if (cachedDataSchema != null) {
-        List<String> selectionColumns = SelectionOperatorUtils
-            
.getSelectionColumns(brokerRequest.getSelections().getSelectionColumns(), 
cachedDataSchema);
-        brokerResponseNative.setSelectionResults(new 
SelectionResults(selectionColumns, new ArrayList<>(0)));
+        if (brokerRequest.isSetSelections()) {
+          List<String> selectionColumns =
+              
SelectionOperatorUtils.getSelectionColumns(brokerRequest.getSelections().getSelectionColumns(),
+                  cachedDataSchema);
+          brokerResponseNative.setSelectionResults(new 
SelectionResults(selectionColumns, new ArrayList<>(0)));
+        } else if (brokerRequest.isSetGroupBy() && queryOptions != null && 
SQL.equalsIgnoreCase(
+            queryOptions.get(QueryOptionKey.GROUP_BY_MODE)) && 
SQL.equalsIgnoreCase(
+            queryOptions.get(QueryOptionKey.RESPONSE_FORMAT))) {
 
 Review comment:
   Yes, user can specify `"queryOptions":"groupByMode=sql;responseFormat=sql"`
   By default we will be `pql,pql`
   `sql,sql` is the end state
   In the interim, user can do `sql,pql`.
   `pql,sql` is the only invalid combination, and it will default to `pql,pql`.
   
   This is based on our (Mayank, Kishore, Neha) conversation, where we 
discussed that only allowing it on `sql:query..` won't be good, for the 
following reasons:
   1. We are not sure how long it will take us to completely get to sql. Use 
will have to keep changing payload `pql:query` to `sql:query` and back, 
depending on query.  It's more flexible with options. It gives us a clean path 
from `pql,pql` to `sql,sql`.
   2. Enforcing that only "sql" payload will trigger this, will bring in other 
problems, as we saw with the parser (Date column is a special keyword in sql) 
etc.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to