Skip to content

Commit

Permalink
[#351] feat(catalog-lakehouse): make IcebergTableOps#updateTable more…
Browse files Browse the repository at this point in the history
… convenient (#383)

### What changes were proposed in this pull request?

add a new `updateTable` interface in  IcebergTableOps 

### Why are the changes needed?
graviton developer could pass `TableChange` to IcebergTableOps, and no
need to care about details of Iceberg

fixes: #351

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
UT
  • Loading branch information
FANNG1 authored Sep 19, 2023
1 parent 0d00735 commit 4c66ab6
Show file tree
Hide file tree
Showing 5 changed files with 804 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ final class SetProperty implements TableChange {
private final String property;
private final String value;

private SetProperty(String property, String value) {
public SetProperty(String property, String value) {
this.property = property;
this.value = value;
}
Expand Down
9 changes: 9 additions & 0 deletions catalog-lakehouse/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
dependencies {
implementation(project(":common"))
implementation(project(":core"))
implementation(project(":api"))
implementation(libs.jackson.databind)
implementation(libs.jackson.annotations)
implementation(libs.jackson.datatype.jdk8)
Expand All @@ -24,6 +25,14 @@ dependencies {
implementation(libs.bundles.jetty)
implementation(libs.bundles.jersey)
implementation(libs.bundles.iceberg)
implementation(libs.substrait.java.core) {
exclude("com.fasterxml.jackson.core")
exclude("com.fasterxml.jackson.datatype")
exclude("com.fasterxml.jackson.dataformat")
exclude("com.google.protobuf")
exclude("com.google.code.findbugs")
exclude("org.slf4j")
}

compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*/
package com.datastrato.graviton.catalog.lakehouse.iceberg.ops;

import com.datastrato.graviton.catalog.lakehouse.iceberg.ops.IcebergTableOpsHelper.IcebergTableChange;
import com.datastrato.graviton.catalog.lakehouse.iceberg.utils.IcebergCatalogUtil;
import com.google.common.base.Preconditions;
import java.util.Optional;
import javax.ws.rs.NotSupportedException;
import org.apache.iceberg.Transaction;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.SupportsNamespaces;
Expand All @@ -31,7 +33,7 @@ public class IcebergTableOps {

private static final Logger LOG = LoggerFactory.getLogger(IcebergTableOps.class);

private Catalog catalog;
protected Catalog catalog;
private SupportsNamespaces asNamespaceCatalog;
private final String DEFAULT_ICEBERG_CATALOG_TYPE = "memory";

Expand All @@ -42,6 +44,10 @@ public IcebergTableOps() {
}
}

public IcebergTableOpsHelper createIcebergTableOpsHelper() {
return new IcebergTableOpsHelper(catalog);
}

private void validateNamespace(Optional<Namespace> namespace) {
namespace.ifPresent(
n ->
Expand Down Expand Up @@ -115,4 +121,10 @@ public LoadTableResponse updateTable(
TableIdentifier tableIdentifier, UpdateTableRequest updateTableRequest) {
return CatalogHandlers.updateTable(catalog, tableIdentifier, updateTableRequest);
}

public LoadTableResponse updateTable(IcebergTableChange icebergTableChange) {
Transaction transaction = icebergTableChange.getTransaction();
transaction.commitTransaction();
return loadTable(icebergTableChange.getTableIdentifier());
}
}
Loading

0 comments on commit 4c66ab6

Please sign in to comment.