Hive: Refactor TestHiveCatalog tests to use the core CatalogTests#8918
Hive: Refactor TestHiveCatalog tests to use the core CatalogTests#8918nastra merged 1 commit intoapache:mainfrom
Conversation
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveMetastoreSetup.java
Outdated
Show resolved
Hide resolved
| } catch (InterruptedException e) { | ||
| Thread.currentThread().interrupt(); | ||
| throw new RuntimeException("Interrupted in call to rename", e); | ||
| } catch (RuntimeException e) { |
There was a problem hiding this comment.
Can you paste the complete callstack? I am wondering why it is not coming as AlreadyExistsException in line 254
There was a problem hiding this comment.
java.lang.AssertionError: Expecting actual throwable to be an instance of: org.apache.iceberg.exceptions.AlreadyExistsException but was: java.lang.RuntimeException: InvalidOperationException(message:new table newdb.table_renamed already exists) at org.apache.iceberg.relocated.com.google.common.base.Throwables.propagate(Throwables.java:231) at org.apache.iceberg.common.DynMethods$UnboundMethod.invoke(DynMethods.java:75) at org.apache.iceberg.hive.MetastoreUtil.alterTable(MetastoreUtil.java:75)
There was a problem hiding this comment.
So, this change is needed now because CatalogTests is expecting that particular type of message?
There was a problem hiding this comment.
Taking a quick look, I do not like this change.
Why is this RuntimeException?
This code tries to capture this case:
} catch (AlreadyExistsException e) {
throw new org.apache.iceberg.exceptions.AlreadyExistsException(
"Table already exists: %s", to);
}
Do we have checks for the other cases as well?
My first guess would be that MetastoreUtil.alterTable messes up the Hive exceptions, and maybe all of them are off?
There was a problem hiding this comment.
Also maybe the exceptions thrown are different with different Hive versions?
There was a problem hiding this comment.
From my side:
- I am not sure Remove redundant error propagation check. #9143 is generally ok - maybe there were some reason behind the
RuntimeException, which I am not aware of. - I prefer not to have to unwrap the
RuntimeExceptionin exception handling - We need to understand why it is needed, and remove the root cause
There was a problem hiding this comment.
@pvary @nastra is it a good idea for now to override the corresponding test cases at TestHiveCatalog. and remove this specific RuntimeException handling ?
Currently there is only one test cases which is failing testRenameTableDestinationTableAlreadyExists.
It is failing here.
With a backlog issue we can fix this RuntimeException issue.
WDYT ?
There was a problem hiding this comment.
I'm ok ignoring testRenameTableDestinationTableAlreadyExists() for TestHiveCatalog for now and revert the changes here and then open an issue to follow-up on improving this behavior.
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalogNew.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalogNew.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveMetastoreSetup.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalogNew.java
Outdated
Show resolved
Hide resolved
34be422 to
e9668f8
Compare
| } catch (InterruptedException e) { | ||
| Thread.currentThread().interrupt(); | ||
| throw new RuntimeException("Interrupted in call to rename", e); | ||
| } catch (RuntimeException e) { |
There was a problem hiding this comment.
So, this change is needed now because CatalogTests is expecting that particular type of message?
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveMetastoreSetup.java
Outdated
Show resolved
Hide resolved
| /** | ||
| * 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 |
There was a problem hiding this comment.
Can you please check and remove in this PR only? I don't think it should be a separate change.
There was a problem hiding this comment.
do we still need this comment?
There was a problem hiding this comment.
I have another patch in progress which will do these cleanup.
There was a problem hiding this comment.
independently from the other PR we can remove the entire comment block here as I don't think we need it
There was a problem hiding this comment.
@nk1506 can you please go ahead and remove this entire comment block?
| try { | ||
| Table table = | ||
| catalog | ||
| catalog() |
There was a problem hiding this comment.
If you keep a local variable HiveCatalog catalog and initialize it in before(), you don't have to change to a method call everywhere;
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Outdated
Show resolved
Hide resolved
e9668f8 to
d7456e9
Compare
|
|
||
| @Test | ||
| public void testDropNamespace() throws TException { | ||
| public void testDropNamespace() { |
There was a problem hiding this comment.
Since it's overriding with Base class testDropNamespace
There was a problem hiding this comment.
it's better to rename the method rather than override it, since it's testing custom logic here
There was a problem hiding this comment.
As per previous comment , I reverted the renaming.
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Show resolved
Hide resolved
d7456e9 to
c9b0078
Compare
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Outdated
Show resolved
Hide resolved
530933f to
0c54560
Compare
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveMetastoreExtension.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
Outdated
Show resolved
Hide resolved
| // 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))) { |
There was a problem hiding this comment.
I think here we should examine the exact cause rather than just looking at the exception message.
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
| /* | ||
| * This meta-setup has been deprecated; use {@link HiveMetastoreExtension} instead. | ||
| * */ | ||
| @Deprecated |
There was a problem hiding this comment.
After this could you please create a PR to remove this class?
Or in this one, if it is trivial...
There was a problem hiding this comment.
@nk1506 can you please open a proper PR against the Iceberg repo with those changes where subclasses of HiveMetastoreTest are moved to JUnit5?
That being said, I don't think the deprecation here is necessary, since HiveMetastoreTest could also be seen as a Junit4-thing, whereas the HiveMetastoreExtension is what you would use for JUnit5.
5fdb2f5 to
13e4a4f
Compare
59d89a4 to
768d7c6
Compare
I was in the impression to make With overloaded constructor it will have hybrid flavour. Please share your thoughts. |
|
I agree that creating the database inside the extension should be made configurable |
|
@nk1506 @ajantha-bhat I've opened #9288 to make the extension configurable. |
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Show resolved
Hide resolved
768d7c6 to
51a616b
Compare
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Show resolved
Hide resolved
|
|
||
| @ParameterizedTest | ||
| @ValueSource(ints = {1, 2}) | ||
| public void testReplaceTxnBuilder(int formatVersion) { |
There was a problem hiding this comment.
testReplaceTxnBuilder -> testReplaceTransaction
| } | ||
|
|
||
| @Test | ||
| public void testListNamespace() throws TException { |
There was a problem hiding this comment.
testListNamespace -> testListNamespaces .
| } | ||
|
|
||
| @Test | ||
| public void testSetNamespaceProperties() throws TException { |
There was a problem hiding this comment.
testSetNamespaceProperties -> testSetNamespaceProperties
| } | ||
|
|
||
| @Test | ||
| public void testRemoveNamespaceProperties() throws TException { |
There was a problem hiding this comment.
testRemoveNamespaceProperties -> testRemoveNamespaceProperties
| } | ||
|
|
||
| @Test | ||
| public void testRegisterTable() { |
| } | ||
|
|
||
| @Test | ||
| public void testRegisterExistingTable() { |
There was a problem hiding this comment.
testRegisterExistingTable -> testRegisterExistingTable
|
Thanks @ajantha-bhat and @nastra for recommending configurable approach for |
51a616b to
3f69333
Compare
ajantha-bhat
left a comment
There was a problem hiding this comment.
We just have to conclude #8918 (comment)
May be ask in #dev slack channel or in a mailing list.
We can work on it even as a follow up IMO.
rest of the change LGTM.
3f69333 to
e95be19
Compare
| catalog.createNamespace(ns); | ||
| } | ||
|
|
||
| Assertions.assertThat(catalog.tableExists(TABLE)) |
There was a problem hiding this comment.
please add a TODO and mention the issue that addresses this. Also it's not clear what exactly is different from the test in CatalogTests, so please add a comment
e95be19 to
7174c7f
Compare
| Assertions.assertThat(catalog.tableExists(renamedTable)) | ||
| .as("Destination table should exist after create") | ||
| .isTrue(); | ||
| // With fix of issues#9289,it should match with CatalogTests and expect |
There was a problem hiding this comment.
nit: would be good to add a newline before this line for better readability
7174c7f to
e9722db
Compare
Currently HiveTests are not using the Core catalog tests. Ideally unlike other catalog Nessie , JDBC, Hive should also extent the core CatalogTests.
Depends upon feedback other duplicate tests will be removed and remaining will be moved to this new class.