davseitsev commented on code in PR #12892:
URL: https://github.com/apache/iceberg/pull/12892#discussion_r2568821646
##########
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java:
##########
@@ -986,8 +996,96 @@ public void testRenameTable() {
assertEmpty("Should not contain table after drop", catalog, NS);
}
+ @Test
+ public void testCreateTableInUniqueLocation() {
+ assumeThat(supportsTableRename())
+ .as("Only valid for catalogs that support table rename operation")
+ .isTrue();
+
+ ImmutableMap<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(supportsTableRename())
+ .as("Only valid for catalogs that support table rename operation")
+ .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 PURGE, %s must exist",
TABLE).isTrue();
Review Comment:
Thanks, I've changed the text
--
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]