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
yunqing-wei committed Oct 13, 2023
1 parent 7b72f29 commit 1359824
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.datastrato.graviton.integration.test.util.GravitonITUtils;
import com.datastrato.graviton.rel.Distribution;
import com.datastrato.graviton.rel.Schema;
import com.datastrato.graviton.rel.SchemaChange;
import com.datastrato.graviton.rel.SortOrder;
import com.datastrato.graviton.rel.SortOrder.Direction;
import com.datastrato.graviton.rel.SortOrder.NullOrdering;
Expand Down Expand Up @@ -59,16 +60,14 @@ public class CatalogIcebergIT extends AbstractIT {
public static String ICEBERG_COL_NAME1 = "iceberg_col_name1";
public static String ICEBERG_COL_NAME2 = "iceberg_col_name2";
public static String ICEBERG_COL_NAME3 = "iceberg_col_name3";
static String ICEBERG_METASTORE_URIS = "thrift://localhost:9083";

private static final String provider = "lakehouse-iceberg";

private static GravitonMetaLake metalake;

private static Catalog catalog;

@BeforeAll
public static void startup() throws Exception {
public static void startup() {
createMetalake();
createCatalog();
createSchema();
Expand All @@ -81,7 +80,7 @@ public static void stop() {
}

@AfterEach
private void resetSchema() throws TException, InterruptedException {
private void resetSchema() {
clearTableAndSchema();
createSchema();
}
Expand Down Expand Up @@ -181,6 +180,11 @@ void testLoadIcebergSchema() {
schemaMap =
Arrays.stream(nameIdentifiers).collect(Collectors.toMap(NameIdentifier::name, v -> v));
Assertions.assertTrue(schemaMap.containsKey(testSchemaName));

schemas.alterSchema(ident, SchemaChange.setProperty("t1", "v1"));
Schema schema = schemas.loadSchema(ident);
Assertions.assertTrue(schema.properties().containsKey("t1"));

schemas.dropSchema(ident, false);
Assertions.assertThrows(NoSuchSchemaException.class, () -> schemas.loadSchema(ident));
nameIdentifiers = schemas.listSchemas(Namespace.of(metalakeName, catalogName));
Expand Down Expand Up @@ -220,31 +224,31 @@ void testCreateAndLoadIcebergTable() {
Map<String, String> resultProp = createdTable.properties();
for (Map.Entry<String, String> entry : properties.entrySet()) {
Assertions.assertTrue(resultProp.containsKey(entry.getKey()));
Assertions.assertEquals(resultProp.get(entry.getKey()), entry.getValue());
Assertions.assertEquals(entry.getValue(), resultProp.get(entry.getKey()));
}
Assertions.assertEquals(createdTable.columns().length, columns.length);

for (int i = 0; i < columns.length; i++) {
Assertions.assertEquals(createdTable.columns()[i], columns[i]);
}

Assertions.assertEquals(createdTable.partitioning().length, partitioning.length);
Assertions.assertEquals(createdTable.sortOrder().length, sortOrders.length);
Assertions.assertEquals(partitioning.length, createdTable.partitioning().length);
Assertions.assertEquals(sortOrders.length, createdTable.sortOrder().length);

Table loadTable = tableCatalog.loadTable(table);
Assertions.assertEquals(loadTable.name(), tableName);
resultProp = loadTable.properties();
for (Map.Entry<String, String> entry : properties.entrySet()) {
Assertions.assertTrue(resultProp.containsKey(entry.getKey()));
Assertions.assertEquals(resultProp.get(entry.getKey()), entry.getValue());
Assertions.assertEquals(entry.getValue(), resultProp.get(entry.getKey()));
}
Assertions.assertEquals(loadTable.columns().length, columns.length);
for (int i = 0; i < columns.length; i++) {
Assertions.assertEquals(loadTable.columns()[i], columns[i]);
Assertions.assertEquals(columns[i], loadTable.columns()[i]);
}

Assertions.assertEquals(loadTable.partitioning().length, partitioning.length);
Assertions.assertEquals(loadTable.sortOrder().length, sortOrders.length);
Assertions.assertEquals(partitioning.length, loadTable.partitioning().length);
Assertions.assertEquals(sortOrders.length, loadTable.sortOrder().length);

Assertions.assertThrows(
TableAlreadyExistsException.class,
Expand Down

0 comments on commit 1359824

Please sign in to comment.