krvikash commented on code in PR #6591:
URL: https://github.com/apache/iceberg/pull/6591#discussion_r1086244936
##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java:
##########
@@ -1176,4 +1178,37 @@ public void
testDatabaseLocationWithSlashInWarehouseDir() {
Assert.assertEquals("s3://bucket/database.db", database.getLocationUri());
}
+
+ @Test
+ public void testRegisterTable() {
+ TableIdentifier identifier = TableIdentifier.of(DB_NAME, "t1");
+ catalog.createTable(identifier, getTestSchema());
+ Table registeringTable = catalog.loadTable(identifier);
+ catalog.dropTable(identifier, false);
+ TableOperations ops = ((HasTableOperations) registeringTable).operations();
+ String metadataLocation = ((HiveTableOperations)
ops).currentMetadataLocation();
+ Table registeredTable = catalog.registerTable(identifier,
metadataLocation);
+ org.assertj.core.api.Assertions.assertThat(registeredTable).isNotNull();
+ TestHelpers.assertSerializedAndLoadedMetadata(registeringTable,
registeredTable);
+ String expectedMetadataLocation =
+ ((HasTableOperations)
registeredTable).operations().current().metadataFileLocation();
+ org.assertj.core.api.Assertions.assertThat(metadataLocation)
+ .isEqualTo(expectedMetadataLocation);
+
org.assertj.core.api.Assertions.assertThat(catalog.loadTable(identifier)).isNotNull();
+
org.assertj.core.api.Assertions.assertThat(catalog.dropTable(identifier)).isTrue();
+ }
+
+ @Test
+ public void testRegisterExistingTable() {
+ TableIdentifier identifier = TableIdentifier.of(DB_NAME, "t1");
+ catalog.createTable(identifier, getTestSchema());
+ Table registeringTable = catalog.loadTable(identifier);
+ TableOperations ops = ((HasTableOperations) registeringTable).operations();
+ String metadataLocation = ((HiveTableOperations)
ops).currentMetadataLocation();
+ org.assertj.core.api.Assertions.assertThatThrownBy(
+ () -> catalog.registerTable(identifier, metadataLocation))
+ .isInstanceOf(AlreadyExistsException.class)
+ .hasMessage("Table already exists: hivedb.t1");
+ org.assertj.core.api.Assertions.assertThat(catalog.dropTable(identifier,
true)).isTrue();
Review Comment:
`org.junit.jupiter.api.Assertions` from another package was imported
already, which is why IDE automatically used full class reference
`org.assertj.core.api.Assertions` while pasting the code.
I have now imported `org.assertj.core.api.Assertions.assertThat` static in
the class.
--
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]