Skip to content

Commit

Permalink
[FLINK-36756][sql-gateway] Bump up the sql gateway rest version (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
fsk119 authored Dec 3, 2024
1 parent 8203192 commit 129da74
Show file tree
Hide file tree
Showing 4 changed files with 403 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
import org.apache.flink.table.gateway.rest.message.session.ConfigureSessionRequestBody;
import org.apache.flink.table.gateway.rest.message.session.SessionHandleIdPathParameter;
import org.apache.flink.table.gateway.rest.message.session.SessionMessageParameters;
import org.apache.flink.table.gateway.rest.util.SqlGatewayRestAPIVersion;

import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;

import java.util.Arrays;
import java.util.Collection;

import static org.apache.flink.table.gateway.rest.util.SqlGatewayRestAPIVersion.V1;
import static org.apache.flink.table.gateway.rest.util.SqlGatewayRestAPIVersion.getHigherVersions;

/** Message headers for configuring a session. */
public class ConfigureSessionHeaders
implements SqlGatewayMessageHeaders<
Expand Down Expand Up @@ -87,7 +88,7 @@ public String getTargetRestEndpointURL() {

@Override
public Collection<? extends RestAPIVersion<?>> getSupportedAPIVersions() {
return Arrays.asList(SqlGatewayRestAPIVersion.V2, SqlGatewayRestAPIVersion.V3);
return getHigherVersions(V1);
}

public static ConfigureSessionHeaders getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;

import java.util.Arrays;
import java.util.Collection;

/** Message headers for completing a statement. */
Expand Down Expand Up @@ -81,7 +80,7 @@ public String getTargetRestEndpointURL() {

@Override
public Collection<? extends RestAPIVersion<?>> getSupportedAPIVersions() {
return Arrays.asList(SqlGatewayRestAPIVersion.V2, SqlGatewayRestAPIVersion.V3);
return SqlGatewayRestAPIVersion.getHigherVersions(SqlGatewayRestAPIVersion.V1);
}

public static CompleteStatementHeaders getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public enum SqlGatewayRestAPIVersion
V2(false, true),

// V3 introduces materialized table related APIs
V3(true, true);
V3(false, true),

// V4 supports to deploy script to application cluster
V4(true, true);

private final boolean isDefaultVersion;

Expand Down Expand Up @@ -139,4 +142,13 @@ public static SqlGatewayRestAPIVersion getDefaultVersion() {

return versions.get(0);
}

/** Get higher versions comparing to the input version. */
public static List<SqlGatewayRestAPIVersion> getHigherVersions(
SqlGatewayRestAPIVersion version) {
return Arrays.stream(SqlGatewayRestAPIVersion.values())
.filter(SqlGatewayRestAPIVersion::isStableVersion)
.filter(v -> v.compareTo(version) > 0)
.collect(Collectors.toList());
}
}
Loading

0 comments on commit 129da74

Please sign in to comment.