Skip to content

Commit 915ce8a

Browse files
committed
Fix partialCancel statement path redirection
1 parent 487137c commit 915ce8a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package io.trino.gateway.ha.handler;
1515

16+
import com.google.common.collect.ImmutableSet;
1617
import com.google.common.io.CharStreams;
1718
import io.airlift.log.Logger;
1819
import io.trino.gateway.ha.router.TrinoQueryProperties;
@@ -52,6 +53,8 @@ public final class ProxyUtils
5253
* capitalization.
5354
*/
5455
private static final Pattern QUERY_ID_PARAM_PATTERN = Pattern.compile(".*(?:%2F|(?i)query_?id(?-i)=|^)(\\d+_\\d+_\\d+_\\w+).*");
56+
public static final ImmutableSet<String> QUERY_STATE_PATH = ImmutableSet.of("queued", "scheduled", "executing");
57+
public static final String PARTIAL_CANCEL_PATH = "partialCancel";
5558

5659
private ProxyUtils() {}
5760

@@ -100,10 +103,10 @@ public static Optional<String> extractQueryIdIfPresent(String path, String query
100103
path = path.replace(matchingStatementPath.orElse(V1_QUERY_PATH), "");
101104
String[] tokens = path.split("/");
102105
if (tokens.length >= 2) {
103-
if (tokens[1].equals("queued")
104-
|| tokens[1].equals("scheduled")
105-
|| tokens[1].equals("executing")
106-
|| tokens[1].equals("partialCancel")) {
106+
if (tokens.length >= 3 && QUERY_STATE_PATH.contains(tokens[1])) {
107+
if (tokens.length >= 4 && tokens[2].equals(PARTIAL_CANCEL_PATH)) {
108+
return Optional.of(tokens[3]);
109+
}
107110
return Optional.of(tokens[2]);
108111
}
109112
return Optional.of(tokens[1]);

0 commit comments

Comments
 (0)