Skip to content

Commit

Permalink
support start with Gravitino
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed Jul 2, 2024
1 parent 88ea08c commit 843e9f4
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 385 deletions.
16 changes: 3 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -547,27 +547,17 @@ tasks {
val compileIcebergRESTServer by registering {
dependsOn("iceberg-rest-server:copyLibs")
group = "Iceberg REST server distribution"
outputs.dir(projectDir.dir("distribution/${rootProject.name}-iceberg-rest-server"))
outputs.dir(projectDir.dir("distribution/package/iceberg-rest-server"))
doLast {
copy {
from(projectDir.dir("conf")) { into("${rootProject.name}-iceberg-rest-server/conf") }
from(projectDir.dir("bin")) { into("${rootProject.name}-iceberg-rest-server/bin") }
from(projectDir.dir("conf")) { into("package/iceberg-rest-server/conf") }
from(projectDir.dir("bin")) { into("package/iceberg-rest-server/bin") }
into(outputDir)
rename { fileName ->
fileName.replace(".template", "")
}
fileMode = 0b111101101
}
copy {
from(projectDir.dir("licenses")) { into("${rootProject.name}-iceberg-rest-server/licenses") }
from(projectDir.file("LICENSE.bin")) { into("${rootProject.name}-iceberg-rest-server") }
from(projectDir.file("NOTICE.bin")) { into("${rootProject.name}-iceberg-rest-server") }
from(projectDir.file("README.md")) { into("${rootProject.name}-iceberg-rest-server") }
into(outputDir)
rename { fileName ->
fileName.replace(".bin", "")
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.Namespace;
import com.datastrato.gravitino.SchemaChange;
import com.datastrato.gravitino.catalog.lakehouse.iceberg.ops.IcebergTableOps;
import com.datastrato.gravitino.catalog.lakehouse.iceberg.ops.IcebergTableOpsHelper;
import com.datastrato.gravitino.connector.CatalogInfo;
import com.datastrato.gravitino.connector.CatalogOperations;
Expand All @@ -21,6 +20,8 @@
import com.datastrato.gravitino.exceptions.NonEmptySchemaException;
import com.datastrato.gravitino.exceptions.SchemaAlreadyExistsException;
import com.datastrato.gravitino.exceptions.TableAlreadyExistsException;
import com.datastrato.gravitino.iceberg.common.IcebergConfig;
import com.datastrato.gravitino.iceberg.common.ops.IcebergTableOps;
import com.datastrato.gravitino.meta.AuditInfo;
import com.datastrato.gravitino.rel.Column;
import com.datastrato.gravitino.rel.Table;
Expand All @@ -44,6 +45,7 @@
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.iceberg.Transaction;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.AlreadyExistsException;
import org.apache.iceberg.exceptions.NamespaceNotEmptyException;
Expand All @@ -58,6 +60,7 @@
import org.slf4j.LoggerFactory;

/** Operations for interacting with the Iceberg catalog in Gravitino. */
@SuppressWarnings("UnusedVariable")
public class IcebergCatalogOperations implements CatalogOperations, SupportsSchemas, TableCatalog {

private static final String ICEBERG_TABLE_DOES_NOT_EXIST_MSG = "Iceberg table does not exist: %s";
Expand Down Expand Up @@ -96,7 +99,7 @@ public void initialize(
IcebergConfig icebergConfig = new IcebergConfig(resultConf);

this.icebergTableOps = new IcebergTableOps(icebergConfig);
this.icebergTableOpsHelper = icebergTableOps.createIcebergTableOpsHelper();
this.icebergTableOpsHelper = new IcebergTableOpsHelper(icebergTableOps.getCatalog());
}

/** Closes the Iceberg catalog and releases the associated client pool. */
Expand Down Expand Up @@ -392,7 +395,10 @@ private Table internalUpdateTable(NameIdentifier tableIdent, TableChange... chan
IcebergTableOpsHelper.IcebergTableChange icebergTableChange =
icebergTableOpsHelper.buildIcebergTableChanges(
NameIdentifier.of(levels[levels.length - 1], tableIdent.name()), changes);
LoadTableResponse loadTableResponse = icebergTableOps.updateTable(icebergTableChange);
Transaction transaction = icebergTableChange.getTransaction();
transaction.commitTransaction();
LoadTableResponse loadTableResponse =
icebergTableOps.loadTable(icebergTableChange.getTableIdentifier());
loadTableResponse.validate();
return IcebergTable.fromIcebergTable(loadTableResponse.tableMetadata(), tableIdent.name());
} catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
Expand Down

This file was deleted.

Loading

0 comments on commit 843e9f4

Please sign in to comment.