-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Nessie Catalog in Iceberg connector
This PR integrates the (Nessie catalog functionality)[https://github.com/apache/iceberg/tree/master/nessie/src/main/java/org/apache/iceberg/nessie] to the Iceberg connector. It adds the following new things: * a new `CatalogType` called `NESSIE` * an `IcebergNessieCatalogModule` that sets up all necessary dependencies (including a client to connect to the Nessie server) * a `NessieConfig` that includes configuration settings required for Nessie * `TrinoNessieCatalog` + `NessieIcebergTableOperations` that implement the main behavior of the catalog * some unit and integration tests that verify that the Iceberg connector works with Nessie (note that the integration test requires a Nessie server to be started, which is being done via the `nessie-apprunner-maven-plugin`prior to the integration-test phase) This PR does not yet include documentation updates, as I'd like to get some feedback first before addressing that.
- Loading branch information
Showing
14 changed files
with
1,412 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,6 @@ public enum CatalogType | |
TESTING_FILE_METASTORE, | ||
HIVE_METASTORE, | ||
GLUE, | ||
NESSIE, | ||
/**/; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...berg/src/main/java/io/trino/plugin/iceberg/catalog/nessie/IcebergNessieCatalogModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.iceberg.catalog.nessie; | ||
|
||
import com.google.inject.Binder; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Scopes; | ||
import io.airlift.configuration.AbstractConfigurationAwareModule; | ||
import io.trino.plugin.iceberg.catalog.IcebergTableOperationsProvider; | ||
import io.trino.plugin.iceberg.catalog.TrinoCatalogFactory; | ||
import org.projectnessie.client.api.NessieApiV1; | ||
import org.projectnessie.client.http.HttpClientBuilder; | ||
|
||
import javax.inject.Provider; | ||
|
||
import static io.airlift.configuration.ConfigBinder.configBinder; | ||
import static org.weakref.jmx.guice.ExportBinder.newExporter; | ||
|
||
public class IcebergNessieCatalogModule | ||
extends AbstractConfigurationAwareModule | ||
{ | ||
@Override | ||
protected void setup(Binder binder) | ||
{ | ||
configBinder(binder).bindConfig(NessieConfig.class); | ||
binder.bind(UpdateableReference.class); | ||
binder.bind(NessieApiV1.class).toProvider(NessieApiProvider.class).in(Scopes.SINGLETON); | ||
binder.bind(IcebergTableOperationsProvider.class).to(NessieIcebergTableOperationsProvider.class).in(Scopes.SINGLETON); | ||
newExporter(binder).export(IcebergTableOperationsProvider.class).withGeneratedName(); | ||
binder.bind(TrinoCatalogFactory.class).to(TrinoNessieCatalogFactory.class).in(Scopes.SINGLETON); | ||
newExporter(binder).export(TrinoCatalogFactory.class).withGeneratedName(); | ||
} | ||
|
||
public static class NessieApiProvider | ||
implements Provider<NessieApiV1> | ||
{ | ||
private final NessieConfig nessieConfig; | ||
|
||
@Inject | ||
public NessieApiProvider(NessieConfig nessieConfig) | ||
{ | ||
this.nessieConfig = nessieConfig; | ||
} | ||
|
||
@Override | ||
public NessieApiV1 get() | ||
{ | ||
return HttpClientBuilder.builder() | ||
.withUri(nessieConfig.getServerUri()) | ||
.build(NessieApiV1.class); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/nessie/NessieConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.iceberg.catalog.nessie; | ||
|
||
import io.airlift.configuration.Config; | ||
import io.airlift.configuration.ConfigDescription; | ||
|
||
import javax.validation.constraints.NotEmpty; | ||
|
||
public class NessieConfig | ||
{ | ||
private String defaultReferenceName = "main"; | ||
private String serverUri = "http://localhost:19120/api/v1"; | ||
private String warehouseDir; | ||
|
||
public String getDefaultReferenceName() | ||
{ | ||
return defaultReferenceName; | ||
} | ||
|
||
@Config("iceberg.nessie.ref") | ||
@ConfigDescription("The default Nessie reference to work on") | ||
public NessieConfig setDefaultReferenceName(String defaultReferenceName) | ||
{ | ||
this.defaultReferenceName = defaultReferenceName; | ||
return this; | ||
} | ||
|
||
public String getServerUri() | ||
{ | ||
return serverUri; | ||
} | ||
|
||
@Config("iceberg.nessie.uri") | ||
@ConfigDescription("The URI to connect to the Nessie server") | ||
public NessieConfig setServerUri(String serverUri) | ||
{ | ||
this.serverUri = serverUri; | ||
return this; | ||
} | ||
|
||
@NotEmpty | ||
public String getWarehouseDir() | ||
{ | ||
return warehouseDir; | ||
} | ||
|
||
@Config("iceberg.nessie.warehouse") | ||
@ConfigDescription("The default warehouse to use for Nessie") | ||
public NessieConfig setWarehouseDir(String warehouseDir) | ||
{ | ||
this.warehouseDir = warehouseDir; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.