Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nk1506 committed Nov 25, 2023
1 parent 6c78294 commit 13e4a4f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ public void renameTable(TableIdentifier from, TableIdentifier originalTo) {
// in case of table already exists,
// Hive rename operation throws exception as
// java.lang.RuntimeException:InvalidOperationException(message:new table <> already exists)
if (e.getMessage().contains(String.format("new table %s already exists)", to))) {
if (e.getCause() instanceof InvalidOperationException
&& e.getCause().getMessage() != null
&& e.getCause().getMessage().contains(String.format("new table %s already exists", to))) {
throw new org.apache.iceberg.exceptions.AlreadyExistsException(
"Table already exists: %s", to);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected void doCommit(TableMetadata base, TableMetadata metadata) {
String baseMetadataLocation = base != null ? base.metadataFileLocation() : null;
if (!Objects.equals(baseMetadataLocation, metadataLocation)) {
throw new CommitFailedException(
"Cannot commit, Base metadata location '%s' is not same as the current table metadata location '%s' for %s.%s",
"Cannot commit: Base metadata location '%s' is not same as the current table metadata location '%s' for %s.%s",
baseMetadataLocation, metadataLocation, database, tableName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

/*
* This meta-setup has been deprecated; use {@link HiveMetastoreExtension} instead.
* */
@Deprecated
public abstract class HiveMetastoreTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

/**
* Run all the tests from abstract of {@link CatalogTests}. Also, a few specific tests for HIVE too.
* There could be some duplicated tests that are already being covered with {@link CatalogTests}
* //TODO: remove duplicate tests with {@link CatalogTests}.Also use the DB/TABLE/SCHEMA from {@link
* CatalogTests}
*/
public class TestHiveCatalog extends CatalogTests<HiveCatalog> {
private static ImmutableMap meta =
ImmutableMap.of(
Expand All @@ -115,7 +109,7 @@ public class TestHiveCatalog extends CatalogTests<HiveCatalog> {
new HiveMetastoreExtension(DB_NAME, Collections.emptyMap());

@BeforeEach
public void setup() {
public void beforeEach() {
catalog =
(HiveCatalog)
CatalogUtil.loadCatalog(
Expand Down Expand Up @@ -217,8 +211,8 @@ public void testInitialize() {
assertThatNoException()
.isThrownBy(
() -> {
HiveCatalog catalog = new HiveCatalog();
catalog.initialize("hive", Maps.newHashMap());
HiveCatalog hiveCatalog = new HiveCatalog();
hiveCatalog.initialize("hive", Maps.newHashMap());
});
}

Expand All @@ -227,8 +221,8 @@ public void testToStringWithoutSetConf() {
assertThatNoException()
.isThrownBy(
() -> {
HiveCatalog catalog = new HiveCatalog();
catalog.toString();
HiveCatalog hiveCatalog = new HiveCatalog();
hiveCatalog.toString();
});
}

Expand All @@ -237,11 +231,12 @@ public void testInitializeCatalogWithProperties() {
Map<String, String> properties = Maps.newHashMap();
properties.put("uri", "thrift://examplehost:9083");
properties.put("warehouse", "/user/hive/testwarehouse");
HiveCatalog catalog = new HiveCatalog();
catalog.initialize("hive", properties);
HiveCatalog hiveCatalog = new HiveCatalog();
hiveCatalog.initialize("hive", properties);

assertThat(catalog.getConf().get("hive.metastore.uris")).isEqualTo("thrift://examplehost:9083");
assertThat(catalog.getConf().get("hive.metastore.warehouse.dir"))
assertThat(hiveCatalog.getConf().get("hive.metastore.uris"))
.isEqualTo("thrift://examplehost:9083");
assertThat(hiveCatalog.getConf().get("hive.metastore.warehouse.dir"))
.isEqualTo("/user/hive/testwarehouse");
}

Expand Down Expand Up @@ -1184,10 +1179,10 @@ public void testDatabaseLocationWithSlashInWarehouseDir() {
// With a trailing slash
conf.set("hive.metastore.warehouse.dir", "s3://bucket/");

HiveCatalog catalog = new HiveCatalog();
catalog.setConf(conf);
HiveCatalog hiveCatalog = new HiveCatalog();
hiveCatalog.setConf(conf);

Database database = catalog.convertToDatabase(Namespace.of("database"), ImmutableMap.of());
Database database = hiveCatalog.convertToDatabase(Namespace.of("database"), ImmutableMap.of());

assertThat(database.getLocationUri()).isEqualTo("s3://bucket/database.db");
}
Expand Down

0 comments on commit 13e4a4f

Please sign in to comment.