FANNG1 commented on code in PR #9572:
URL: https://github.com/apache/gravitino/pull/9572#discussion_r2647685686
##########
catalogs/catalog-lakehouse-iceberg/src/test/java/org/apache/gravitino/catalog/lakehouse/iceberg/TestIcebergTable.java:
##########
@@ -491,6 +491,91 @@ public void testAlterIcebergTable() {
Assertions.assertArrayEquals(createdTable.partitioning(),
alteredTable.partitioning());
}
+ @Test
+ public void testRenameTableAcrossSchema() {
+ NameIdentifier tableIdentifier =
+ NameIdentifier.of(
+ META_LAKE_NAME, icebergCatalog.name(), icebergSchema.name(),
"test_iceberg_table");
+ Map<String, String> properties = Maps.newHashMap();
+ properties.put("key1", "val1");
+
+ IcebergColumn col1 =
+ IcebergColumn.builder()
+ .withName("col_1")
+ .withType(Types.IntegerType.get())
+ .withComment(ICEBERG_COMMENT)
+ .build();
+ Column[] columns = new Column[] {col1};
+
+ String targetSchemaName = "target_schema_" + genRandomName();
+ NameIdentifier targetSchemaIdent =
+ NameIdentifier.of(META_LAKE_NAME, icebergCatalog.name(),
targetSchemaName);
+ NameIdentifier renamedIdentifier =
+ NameIdentifier.of(META_LAKE_NAME, icebergCatalog.name(),
targetSchemaName, "renamed_table");
+
+ try {
+ icebergCatalogOperations.createSchema(targetSchemaIdent,
ICEBERG_COMMENT, Maps.newHashMap());
+ icebergCatalogOperations.createTable(
+ tableIdentifier,
+ columns,
+ ICEBERG_COMMENT,
+ properties,
+ new Transform[0],
+ Distributions.NONE,
+ new SortOrder[0]);
+
+ icebergCatalogOperations.alterTable(
+ tableIdentifier, TableChange.rename("renamed_table",
targetSchemaName));
+
+
Assertions.assertFalse(icebergCatalogOperations.tableExists(tableIdentifier));
+
Assertions.assertTrue(icebergCatalogOperations.tableExists(renamedIdentifier));
+ Assertions.assertEquals(
+ "renamed_table",
icebergCatalogOperations.loadTable(renamedIdentifier).name());
+ } finally {
+ if (icebergCatalogOperations.tableExists(renamedIdentifier)) {
+ icebergCatalogOperations.dropTable(renamedIdentifier);
+ }
+ icebergCatalogOperations.dropSchema(targetSchemaIdent, false);
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]