Skip to content

Commit

Permalink
[#400] test: Add Catalog-iceberg e2e integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clearvive committed Oct 17, 2023
1 parent 32bb821 commit f4bf989
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.datastrato.graviton.rel.TableCatalog;
import com.datastrato.graviton.rel.TableChange;
import com.datastrato.graviton.rel.transforms.Transform;
import com.datastrato.graviton.utils.MapUtils;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
Expand Down Expand Up @@ -478,7 +479,7 @@ public Table createTable(
SortOrder[] sortOrders)
throws NoSuchSchemaException, TableAlreadyExistsException {
try {
if(!Distribution.NONE.equals(distribution)) {
if (!Distribution.NONE.equals(distribution)) {
throw new UnsupportedOperationException("Iceberg does not support distribution");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.datastrato.graviton.meta.CatalogEntity;
import com.datastrato.graviton.rel.Column;
import com.datastrato.graviton.rel.Distribution;
import com.datastrato.graviton.rel.Distribution.Strategy;
import com.datastrato.graviton.rel.SortOrder;
import com.datastrato.graviton.rel.SortOrder.Direction;
import com.datastrato.graviton.rel.SortOrder.NullOrdering;
Expand Down Expand Up @@ -107,14 +106,6 @@ private static CatalogEntity createDefaultCatalogEntity() {
return entity;
}

private Distribution createDistribution() {
return Distribution.builder()
.withNumber(10)
.withTransforms(new Transform[] {Transforms.field(new String[] {"col_1"})})
.withStrategy(Strategy.EVEN)
.build();
}

private SortOrder[] createSortOrder() {
return new SortOrder[] {
SortOrder.builder()
Expand Down Expand Up @@ -159,7 +150,7 @@ public void testCreateIcebergTable() throws IOException {
ICEBERG_COMMENT,
properties,
new Transform[0],
null,
Distribution.NONE,
sortOrders);
Assertions.assertEquals(tableIdentifier.name(), table.name());
Assertions.assertEquals(ICEBERG_COMMENT, table.comment());
Expand Down Expand Up @@ -198,7 +189,7 @@ public void testCreateIcebergTable() throws IOException {
ICEBERG_COMMENT,
properties,
new Transform[0],
null,
Distribution.NONE,
sortOrders));
Assertions.assertTrue(exception.getMessage().contains("Table already exists"));
}
Expand Down Expand Up @@ -380,7 +371,7 @@ public void testAlterIcebergTable() {
.build();
Column[] columns = new Column[] {col1, col2};

Distribution distribution = createDistribution();
Distribution distribution = Distribution.NONE;
SortOrder[] sortOrders = createSortOrder();

Table createdTable =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.datastrato.graviton.Catalog;
import com.datastrato.graviton.NameIdentifier;
import com.datastrato.graviton.Namespace;
import com.datastrato.graviton.catalog.lakehouse.iceberg.IcebergCatalogBackend;
import com.datastrato.graviton.client.GravitonMetaLake;
import com.datastrato.graviton.dto.rel.ColumnDTO;
import com.datastrato.graviton.exceptions.NoSuchSchemaException;
Expand Down Expand Up @@ -42,9 +43,11 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

@Tag("graviton-docker-it")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CatalogIcebergIT extends AbstractIT {
public static String metalakeName = GravitonITUtils.genRandomName("CatalogIcebergIT_metalake");
Expand Down Expand Up @@ -108,6 +111,11 @@ private static void createCatalog() {
Map<String, String> properties = Maps.newHashMap();
properties.put("key1", "val1");
properties.put("key2", "val2");
properties.put("catalog-backend", IcebergCatalogBackend.JDBC.name());
properties.put("jdbc-user", "iceberg");
properties.put("jdbc-password", "iceberg");
properties.put("uri", "jdbc:mysql://127.0.0.1:3306/metastore_db?createDatabaseIfNotExist=true");
properties.put("warehouse", "file:///tmp/iceberg");

Catalog createdCatalog =
metalake.createCatalog(
Expand Down

0 comments on commit f4bf989

Please sign in to comment.