xiangfu0 commented on code in PR #20389:
URL: https://github.com/apache/pinot/pull/20389#discussion_r4763481964


##########
pinot-query-runtime/src/test/resources/queries/QueryHints.json:
##########
@@ -283,6 +307,49 @@
       }
     ]
   },
+  "group_by_historical_null_sentinels": {
+    "comments": "The physical optimizer returns two NULL groups even with 
serverReturnFinalResult disabled.",

Review Comment:
   Nit: going by the comments here, this case and the surrogate one below skip 
the v2 optimizer because it returns duplicate groups today even without the 
option. That is a wrong result on master in its own right. An issue for it, 
named in this `comments` field, would give the skip an owner and a reason to 
come back and remove it.



##########
pinot-query-planner/src/test/java/org/apache/pinot/query/QueryEnvironmentTestBase.java:
##########
@@ -333,10 +334,23 @@ public static QueryEnvironment getQueryEnvironment(int 
reducerPort, int port1, i
         int numPartitions = partitionIdToSegmentsMap.size();
         String hostname1 = MockRoutingManagerFactory.toHostname(port1);
         String hostname2 = MockRoutingManagerFactory.toHostname(port2);
+        List<String> server1Segments = 
segmentMap1.getOrDefault(tableNameWithType, List.of());
+        List<String> server2Segments = 
segmentMap2.getOrDefault(tableNameWithType, List.of());
         PartitionInfo[] partitionIdToInfoMap = new 
PartitionInfo[numPartitions];
         for (int i = 0; i < numPartitions; i++) {
-          String hostname = i < (numPartitions / 2) ? hostname1 : hostname2;
-          partitionIdToInfoMap[i] = new PartitionInfo(Set.of(hostname), 
partitionIdToSegmentsMap.get(i));
+          List<String> segments = partitionIdToSegmentsMap.get(i);
+          Set<String> hosts = new HashSet<>();
+          if (segments.isEmpty()) {
+            hosts.add(i < numPartitions / 2 ? hostname1 : hostname2);
+          } else {
+            if (server1Segments.containsAll(segments)) {
+              hosts.add(hostname1);
+            }
+            if (server2Segments.containsAll(segments)) {
+              hosts.add(hostname2);
+            }
+          }
+          partitionIdToInfoMap[i] = new PartitionInfo(hosts, segments);

Review Comment:
   This is what turns CI red on this head. `ResourceBasedQueryPlansTest` fails 
16 cases of `physical_plan_explain_formats` in `ExplainPhysicalPlans.json`, 
which fails Unit Shard 1 and with it the two unit test set checks.
   
   The default fixture puts `SERVER2_SEGMENTS` in partition 1. The old loop 
still reported partition 1 on server 1 because it went by index, and the 
expected implementation plans were written against that. Taking the host from 
where the segments are moves partition 1 to server 2, so the worker lines in 
those 16 plans no longer match (`[1]@localhost:1|[1]` expected, 
`[1]@localhost:2|[1]` found).
   
   I see the same 16 failures locally on this commit, and the suite is back to 
720 of 720 with the old loop restored. The new placement is the consistent one, 
so I'd regenerate the 16 expected plans rather than keep the index rule for the 
default fixture.



##########
pinot-query-planner/src/main/java/org/apache/pinot/query/routing/WorkerManager.java:
##########
@@ -1881,6 +1915,85 @@ static void checkLeafWorkerAssignment(String tableName, 
@Nullable int[] partitio
     }
   }
 
+  /// Checks the ordinary selector's segment assignment. When every partition 
has just one server, a group that
+  /// contains the partition key can finish there. Pin this route so dispatch 
uses the same replica choices.
+  public boolean hasPartitionedGroupByRoute(String tableName, Map<String, 
DataType> groupColumns,
+      PlannerContext planner) {
+    Map<String, PlannerContext.GroupByRoute> routes = 
planner.getGroupByRoutes();
+    if (routes.containsKey(tableName)) {
+      PlannerContext.GroupByRoute checked = routes.get(tableName);
+      return checked != null && 
groupColumns.containsKey(checked.partitionColumn());
+    }

Review Comment:
   Nit: now that only the terminal aggregate can qualify, this check runs at 
most once per query. The cached negative entries are never read again, and the 
note further down about a different aggregate over the same table describes a 
case that can no longer happen. It's harmless, but the cache could go back to 
holding just the one verified route if you want less to maintain.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to