This is an automated email from the ASF dual-hosted git repository.

karan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 9921ac1b194 DartSqlResource: Sort queries by start time. (#17282)
9921ac1b194 is described below

commit 9921ac1b1943a000f8ea57b7e16700a4d2006298
Author: Gian Merlino <[email protected]>
AuthorDate: Tue Oct 8 03:17:21 2024 -0700

    DartSqlResource: Sort queries by start time. (#17282)
    
    * DartSqlResource: Sort queries by start time.
    
    This keeps the list of queries returned by the API in a consistent order.
    
    * Fix test.
---
 .../org/apache/druid/msq/dart/controller/http/DartSqlResource.java    | 4 +++-
 .../apache/druid/msq/dart/controller/http/DartSqlResourceTest.java    | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartSqlResource.java
 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartSqlResource.java
index 37e9f105131..ef6725d455c 100644
--- 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartSqlResource.java
+++ 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartSqlResource.java
@@ -154,7 +154,6 @@ public class DartSqlResource extends SqlResource
         controllerRegistry.getAllHolders()
                           .stream()
                           .map(DartQueryInfo::fromControllerHolder)
-                          
.sorted(Comparator.comparing(DartQueryInfo::getStartTime))
                           .collect(Collectors.toList());
 
     // Add queries from all other servers, if "selfOnly" is not set.
@@ -172,6 +171,9 @@ public class DartSqlResource extends SqlResource
       }
     }
 
+    // Sort queries by start time, breaking ties by query ID, so the list 
comes back in a consistent and nice order.
+    
queries.sort(Comparator.comparing(DartQueryInfo::getStartTime).thenComparing(DartQueryInfo::getDartQueryId));
+
     final GetQueriesResponse response;
     if (stateReadAccess.isAllowed()) {
       // User can READ STATE, so they can see all running queries, as well as 
authentication details.
diff --git 
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
 
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
index db347917872..7ad994cff9e 100644
--- 
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
+++ 
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
@@ -333,7 +333,7 @@ public class DartSqlResourceTest extends MSQTestBase
         "SELECT 2",
         AUTHENTICATOR_NAME,
         DIFFERENT_REGULAR_USER_NAME,
-        DateTimes.of("2000"),
+        DateTimes.of("2001"),
         ControllerHolder.State.RUNNING.toString()
     );
     Mockito.when(dartSqlClient.getRunningQueries(true))


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

Reply via email to