You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "fsk119 (via GitHub)" <gi...@apache.org> on 2023/01/30 02:10:03 UTC
[GitHub] [flink] fsk119 commented on a diff in pull request #21776: [FLINK-30816][sql-client] Fix SQL Client always uses the highest packaged version to connect to gateway
fsk119 commented on code in PR #21776:
URL: https://github.com/apache/flink/pull/21776#discussion_r1090118401
##########
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/ExecutorImpl.java:
##########
@@ -429,4 +453,46 @@ private CompletableFuture<OperationStatusResponseBody> closeOperationAsync(
private OperationHandle getOperationHandle(Supplier<String> handleSupplier) {
return new OperationHandle(UUID.fromString(handleSupplier.get()));
}
+
+ private SqlGatewayRestAPIVersion negotiateVersion() {
+ List<SqlGatewayRestAPIVersion> gatewayVersions =
+ getResponse(
+ sendRequest(
+ GetApiVersionHeaders.getInstance(),
+ EmptyMessageParameters.getInstance(),
+ EmptyRequestBody.getInstance(),
+ // Currently, RestClient always uses the latest REST API
+ // version to build the targetUrl. However, it's possible
+ // that the client REST API version is higher than the
+ // server REST API version. In this case, the gateway will
+ // report Not Found Error to notify the client.
+ //
+ // So, here use the lowest REST API version to get the
+ // remote gateway version list and then determine the
+ // connection version.
+ // TODO: Remove this after the REST Client should allow
+ // to build the target URL without API version.
+ Collections.min(
+ Arrays.stream(SqlGatewayRestAPIVersion.values())
+ .filter(
+ SqlGatewayRestAPIVersion
+ ::isStableVersion)
+ .collect(Collectors.toList()))))
+ .getVersions().stream()
+ .map(SqlGatewayRestAPIVersion::valueOf)
+ .collect(Collectors.toList());
Review Comment:
Considering current implementation is a little hacky, I think it's better we can keep it inside. I think others will not use `getInitialStableVersion`.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org