Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nessie: Support APIv2 client #22215

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Nessie: Support APIv2 client #22215

merged 1 commit into from
Jun 13, 2024

Conversation

ajantha-bhat
Copy link
Member

Description

By default, Nessie API version will be inferred from Nessie URI. If the User has a custom URI which doesn't have version info in the URI, user can configure iceberg.nessie-catalog.client-api-version

Additional context and related issues

Changes at Iceberg repo: apache/iceberg#9459

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( x) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label May 31, 2024
@github-actions github-actions bot added docs iceberg Iceberg connector labels May 31, 2024
@ajantha-bhat
Copy link
Member Author

cc: @dimas-b

icebergNessieCatalogConfig.getDefaultReferenceName(),
null,
ImmutableMap.of());
}

private static String inferVersionFromURI(String uri)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should have exposed this from Iceberg repo
https://github.com/apache/iceberg/blob/2722290a7793dcb4f411aad271d5a22697c696f9/nessie/src/main/java/org/apache/iceberg/nessie/NessieCatalog.java#L136

But that needs another release (1.6.0, which may take a while)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return ClientApiVersion.forName(). This will throw if the API is unknown

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't use ClientApiVersion.valueOf() but returning the ClientApiVersion from inferVersionFromURI

@ajantha-bhat ajantha-bhat marked this pull request as draft May 31, 2024 15:08
@ajantha-bhat ajantha-bhat force-pushed the v2 branch 2 times, most recently from 7fb292a to a12a160 Compare June 1, 2024 08:40
@ajantha-bhat ajantha-bhat marked this pull request as ready for review June 3, 2024 04:51
Copy link

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement. LGTM. Thanks, @ajantha-bhat !

@ajantha-bhat ajantha-bhat requested a review from wendigo June 3, 2024 13:48
@ajantha-bhat
Copy link
Member Author

Test failure is because of existing unrelated flaky test: #18697

@ajantha-bhat
Copy link
Member Author

The failure in ci / pt (default, suite-hive-transactional, is unrelated to the change.

Copy link
Contributor

@wendigo wendigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % comments

@@ -58,9 +63,46 @@ public static NessieIcebergClient createNessieIcebergClient(IcebergNessieCatalog
icebergNessieCatalogConfig.getBearerToken()
.ifPresent(token -> builder.withAuthentication(BearerAuthenticationProvider.create(token)));

return new NessieIcebergClient(builder.build(NessieApiV1.class),
// default version is inferred by uri.
IcebergNessieCatalogConfig.ClientApiVersion apiVersion = icebergNessieCatalogConfig.getClientAPIVersion()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's push this logic to IcebergNessieCatalogConfig so that getClientAPIVersion always return a ClientApiVersion:

    public ClientApiVersion getClientAPIVersion()
    {
        return clientAPIVersion.orElseGet(this::inferVersionFromURI);
    }

Move inferVersionFromURI to IcebergNessieCatalogConfig

Copy link
Member Author

@ajantha-bhat ajantha-bhat Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestIcebergNessieCatalogConfig.testExplicitPropertyMapping is failing because assertAttributesNotEqual(metadata, actual, defaultInstance); will try to get the getClientAPIVersion() using getter method of the default instance (without URI and get the exception).

I think clubbing inferVersionFromURI in the getter is not a good idea. I am planning to call it separately but still keep the inferVersionFromURI method in this class as protected method.

@@ -566,12 +566,15 @@ properties:
* - `iceberg.nessie-catalog.authentication.token`
- The token to use with `BEARER` authentication. Example:
`SXVLUXUhIExFQ0tFUiEK`
* - `iceberg.nessie-catalog.client-api-version`
- Optional client api version to be used instead of inferring from server URI.
Available value is `V1` or `V2`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available values are

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mosabua ptal for documentation changes

@@ -566,12 +566,15 @@ properties:
* - `iceberg.nessie-catalog.authentication.token`
- The token to use with `BEARER` authentication. Example:
`SXVLUXUhIExFQ0tFUiEK`
* - `iceberg.nessie-catalog.client-api-version`
- Optional client api version to be used instead of inferring from server URI.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client API version to be used. By default API version is inferred from the iceberg.nessie-catalog.uri

}

@Config("iceberg.nessie-catalog.client-api-version")
@ConfigDescription("Optional client api version to be used instead of inferring from server URI")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client API version to use

@@ -566,12 +566,15 @@ properties:
* - `iceberg.nessie-catalog.authentication.token`
- The token to use with `BEARER` authentication. Example:
`SXVLUXUhIExFQ0tFUiEK`
* - `iceberg.nessie-catalog.client-api-version`
- Client API version to be used. By default API version is inferred from the `iceberg.nessie-catalog.uri`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Client API version to be used. By default API version is inferred from the `iceberg.nessie-catalog.uri`.
- Optional version of the Client API version to use. By default it is inferred from the `iceberg.nessie-catalog.uri` value.

@@ -566,12 +566,15 @@ properties:
* - `iceberg.nessie-catalog.authentication.token`
- The token to use with `BEARER` authentication. Example:
`SXVLUXUhIExFQ0tFUiEK`
* - `iceberg.nessie-catalog.client-api-version`
- Client API version to be used. By default API version is inferred from the `iceberg.nessie-catalog.uri`.
Available values are `V1` or `V2`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Available values are `V1` or `V2`.
Valid values are `V1` or `V2`.

By default, Nessie API version will be inferred from Nessie URI.
If the User has a custom URI which doesn't have version info in
the URI, user can configure `iceberg.nessie-catalog.client-api-version`
@wendigo wendigo merged commit 7f7fe5d into trinodb:master Jun 13, 2024
52 checks passed
@github-actions github-actions bot added this to the 450 milestone Jun 13, 2024
@JunseoChoJJ
Copy link

JunseoChoJJ commented Jun 13, 2024

@findepi can we use api/v2 now?

for Iceberg connector

additionalCatalogs:
  nessie_catalog: |-
    connector.name=iceberg
    iceberg.catalog.type=nessie
    iceberg.nessie-catalog.uri=http://host_ip:32327/api/v1
    iceberg.nessie-catalog.ref=main

Is it possible to change catalog.uri to http://10.163.20.222:32327/api/v2?

image
still got this error on dbeaver when trying to config with api/v2

@ajantha-bhat
Copy link
Member Author

@JunseoChoJJ: Once the next version of Trino is released, we can use it.
Which version of Trino did you use?

@JunseoChoJJ
Copy link

@ajantha-bhat I used trino 449

@ajantha-bhat
Copy link
Member Author

upcoming release (450) will have this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants