nastra commented on code in PR #12892:
URL: https://github.com/apache/iceberg/pull/12892#discussion_r2745090739
##########
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java:
##########
@@ -1025,6 +1031,94 @@ public void testRenameTable() {
assertEmpty("Should not contain table after drop", catalog, NS);
}
+ @Test
+ public void testCreateTableInUniqueLocation() {
+ assumeThat(supportsUniqueTableLocation())
+ .as("Only valid for catalogs that support unique table location")
+ .isTrue();
+
+ Map<String, String> additionalProperties =
+ ImmutableMap.of(CatalogProperties.UNIQUE_TABLE_LOCATION, "true");
+ C catalog = initCatalog("uniq_path_catalog", additionalProperties);
+
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(NS);
+ }
+
+ catalog.createTable(TABLE, SCHEMA, PartitionSpec.unpartitioned());
+ catalog.renameTable(TABLE, RENAMED_TABLE);
+ catalog.createTable(TABLE, SCHEMA, PartitionSpec.unpartitioned());
+
+ Table table = catalog.loadTable(TABLE);
+ Table renamedTable = catalog.loadTable(RENAMED_TABLE);
+
+ assertThat(table.location())
+ .as("Tables %s and %s have different location", TABLE, RENAMED_TABLE)
+ .isNotEqualTo(renamedTable.location());
+ }
+
+ @Test
+ public void testDropDoesntCorruptTable() throws IOException {
+ assumeThat(supportsUniqueTableLocation())
+ .as("Only valid for catalogs that support unique table location")
+ .isTrue();
+
+ C catalog = catalog();
+
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(TABLE.namespace());
+ }
+
+ PartitionSpec spec = PartitionSpec.unpartitioned();
+
+ Table initialTable = catalog.createTable(TABLE, SCHEMA, spec);
+ String initialFilePath =
initialTable.locationProvider().newDataLocation("data-a.parquet");
+ DataFile dataFile =
+ DataFiles.builder(spec)
+ .withPath(initialFilePath)
+ .withFileSizeInBytes(10)
+ .withRecordCount(2)
+ .build();
+ initialTable.io().newOutputFile(initialFilePath).create().close();
+ initialTable.newAppend().appendFile(dataFile).commit();
+
+ catalog.renameTable(TABLE, RENAMED_TABLE);
+
+ Table newTable = catalog.createTable(TABLE, SCHEMA, spec);
+ String newFilePath =
newTable.locationProvider().newDataLocation("data-b.parquet");
+ DataFile anotherFile =
+ DataFiles.builder(spec)
+ .withPath(newFilePath)
+ .withFileSizeInBytes(10)
+ .withRecordCount(2)
+ .build();
+ newTable.io().newOutputFile(newFilePath).create().close();
+ newTable.newAppend().appendFile(anotherFile).commit();
+
+ catalog.dropTable(RENAMED_TABLE, true);
+
+ assertThat(catalog.tableExists(RENAMED_TABLE))
+ .as("After PURGE, %s must not exist", RENAMED_TABLE)
+ .isFalse();
+ assertThat(catalog.tableExists(TABLE))
+ .as(
+ "After dropping the renamed table with PURGE, the concurrently
recreated table with the original name (%s) must exist",
Review Comment:
it's not really "concurrently" created, so I'd just omit this in the msg
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]