gianm commented on code in PR #19726:
URL: https://github.com/apache/druid/pull/19726#discussion_r3636416189


##########
processing/src/main/java/org/apache/druid/segment/QueryableIndexCursorFactory.java:
##########
@@ -200,15 +201,49 @@ private CursorHolder makeSingleGroupClusteredCursorHolder(
       );
     }
 
+    // A single cluster group is physically sorted by its group ordering (the 
segment ordering with the constant
+    // clustering prefix dropped). When the query wants __time ordering and 
__time is the first non-clustering column,
+    // advertise that __time-first group ordering so the holder reports (and 
honors, incl. descending) time ordering --
+    // matching the multi-group merge path, so the same query does not depend 
on how many groups survive pruning.
+    // Otherwise advertise the full clustering-first segment ordering. Note 
the clustering prefix is constant across
+    // this single group, so both orderings are truthful descriptions of the 
exposed rows.
+    final ClusteredValueGroupsBaseTableSchema summary = 
valueGroup.getSummary();
+    final List<OrderBy> ordering =
+        isGroupTimeOrderingRequested(spec, summary) ? 
summary.getGroupOrdering() : summary.getOrdering();
+
     // groupIndex exposes the group's clustering columns as constant columns, 
no selector wrapper is needed
     return new QueryableIndexCursorHolder(
         groupIndex,
         plan.rebuildCursorBuildSpec(spec, valueGroup),
         QueryableIndexTimeBoundaryInspector.create(groupIndex),
-        valueGroup.getSummary().getOrdering()
+        ordering
     );
   }
 
+  /**

Review Comment:
   IMO this javadoc is too long. Try:
   
   ```
   // Whether the query requested {@code __time} ordering and each cluster 
group is individually
   // time-ordered. In this case, we return time ordered cursors.
   ```



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