Skip to content

Commit

Permalink
Bump Iceberg and Nessie versions
Browse files Browse the repository at this point in the history
- Bump Iceberg to 1.5.0 and Nessie to 0.77.1
- Remove deprecated usage
- InputFile.length is being called since apache/iceberg#9592

Co-authored-by: Eduard Tudenhoefner <[email protected]>
  • Loading branch information
ajantha-bhat and nastra committed Mar 13, 2024
1 parent a4bf353 commit 520ff22
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 27 deletions.
24 changes: 22 additions & 2 deletions plugin/trino-iceberg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<properties>
<air.main.basedir>${project.parent.basedir}</air.main.basedir>
<!-- Nessie version (matching to Iceberg release) must be bumped along with Iceberg version bump to avoid compatibility issues -->
<dep.nessie.version>0.71.1</dep.nessie.version>
<dep.nessie.version>0.77.1</dep.nessie.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -239,12 +239,32 @@
<groupId>org.projectnessie.nessie</groupId>
<artifactId>nessie-client</artifactId>
<version>${dep.nessie.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.projectnessie.nessie</groupId>
<artifactId>nessie-model</artifactId>
<version>${dep.nessie.version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -338,7 +358,7 @@
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.3</version>
<version>5.3.1</version>
<scope>runtime</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import io.trino.plugin.iceberg.catalog.IcebergTableOperationsProvider;
import io.trino.plugin.iceberg.catalog.TrinoCatalogFactory;
import org.apache.iceberg.nessie.NessieIcebergClient;
import org.projectnessie.client.NessieClientBuilder;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.auth.BearerAuthenticationProvider;
import org.projectnessie.client.http.HttpClientBuilder;

import static io.airlift.configuration.ConfigBinder.configBinder;
import static java.lang.Math.toIntExact;
Expand All @@ -47,7 +47,7 @@ protected void setup(Binder binder)
@Singleton
public static NessieIcebergClient createNessieIcebergClient(IcebergNessieCatalogConfig icebergNessieCatalogConfig)
{
HttpClientBuilder builder = HttpClientBuilder.builder()
NessieClientBuilder builder = NessieClientBuilder.createClientBuilderFromSystemSettings()
.withUri(icebergNessieCatalogConfig.getServerUri())
.withDisableCompression(!icebergNessieCatalogConfig.isCompressionEnabled())
.withReadTimeout(toIntExact(icebergNessieCatalogConfig.getReadTimeout().toMillis()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ protected String getRefreshedLocation(boolean invalidateCaches)
protected void commitNewTable(TableMetadata metadata)
{
verify(version.isEmpty(), "commitNewTable called on a table which already exists");
String contentId = table == null ? null : table.getId();
try {
nessieClient.commitTable(null, metadata, writeNewMetadata(metadata, 0), table, toKey(new SchemaTableName(database, this.tableName)));
nessieClient.commitTable(
null,
metadata,
writeNewMetadata(metadata, 0),
contentId,
toKey(database, tableName));
}
catch (NessieNotFoundException e) {
throw new TrinoException(ICEBERG_COMMIT_ERROR, format("Cannot commit: ref '%s' no longer exists", nessieClient.refName()), e);
Expand All @@ -125,8 +131,16 @@ protected void commitNewTable(TableMetadata metadata)
protected void commitToExistingTable(TableMetadata base, TableMetadata metadata)
{
verify(version.orElseThrow() >= 0, "commitToExistingTable called on a new table");
if (table == null) {
table = nessieClient.table(toIdentifier(new SchemaTableName(database, tableName)));
}
try {
nessieClient.commitTable(base, metadata, writeNewMetadata(metadata, version.getAsInt() + 1), table, toKey(new SchemaTableName(database, this.tableName)));
nessieClient.commitTable(
base,
metadata,
writeNewMetadata(metadata, version.getAsInt() + 1),
table.getId(),
toKey(database, tableName));
}
catch (NessieNotFoundException e) {
throw new TrinoException(ICEBERG_COMMIT_ERROR, format("Cannot commit: ref '%s' no longer exists", nessieClient.refName()), e);
Expand All @@ -144,8 +158,9 @@ protected void commitMaterializedViewRefresh(TableMetadata base, TableMetadata m
throw new UnsupportedOperationException();
}

private static ContentKey toKey(SchemaTableName tableName)
private static ContentKey toKey(String databaseName, String tableName)
{
return ContentKey.of(Namespace.parse(tableName.getSchemaName()), tableName.getTableName());
SchemaTableName schemaTableName = new SchemaTableName(databaseName, tableName);
return ContentKey.of(Namespace.parse(schemaTableName.getSchemaName()), schemaTableName.getTableName());
}
}
Loading

0 comments on commit 520ff22

Please sign in to comment.