Skip to content

Commit 9728352

Browse files
gianmcryptoe
authored andcommitted
DartSqlResource: Sort queries by start time. (apache#17282)
* DartSqlResource: Sort queries by start time. This keeps the list of queries returned by the API in a consistent order. * Fix test. (cherry picked from commit 9921ac1)
1 parent 390a63d commit 9728352

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartSqlResource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public GetQueriesResponse doGetRunningQueries(
154154
controllerRegistry.getAllHolders()
155155
.stream()
156156
.map(DartQueryInfo::fromControllerHolder)
157-
.sorted(Comparator.comparing(DartQueryInfo::getStartTime))
158157
.collect(Collectors.toList());
159158

160159
// Add queries from all other servers, if "selfOnly" is not set.
@@ -172,6 +171,9 @@ public GetQueriesResponse doGetRunningQueries(
172171
}
173172
}
174173

174+
// Sort queries by start time, breaking ties by query ID, so the list comes back in a consistent and nice order.
175+
queries.sort(Comparator.comparing(DartQueryInfo::getStartTime).thenComparing(DartQueryInfo::getDartQueryId));
176+
175177
final GetQueriesResponse response;
176178
if (stateReadAccess.isAllowed()) {
177179
// User can READ STATE, so they can see all running queries, as well as authentication details.

extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public void test_getRunningQueries_global_superUser()
333333
"SELECT 2",
334334
AUTHENTICATOR_NAME,
335335
DIFFERENT_REGULAR_USER_NAME,
336-
DateTimes.of("2000"),
336+
DateTimes.of("2001"),
337337
ControllerHolder.State.RUNNING.toString()
338338
);
339339
Mockito.when(dartSqlClient.getRunningQueries(true))

0 commit comments

Comments
 (0)