tthorpeIBM commented on code in PR #3799:
URL: https://github.com/apache/hive/pull/3799#discussion_r1031492455
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java:
##########
@@ -77,8 +77,15 @@ public static DatabaseProduct
determineDatabaseProduct(String productName,
Configuration conf) {
DbType dbt;
+ // Check if we are using an external database product
+ boolean isExternal = MetastoreConf.getBoolVar(conf,
ConfVars.USE_CUSTOM_RDBMS);
+
if (theDatabaseProduct != null) {
- Preconditions.checkState(theDatabaseProduct.dbType ==
getDbType(productName));
+ dbt = getDbType(productName);
+ if (isExternal) {
+ dbt = DbType.CUSTOM;
+ }
+ Preconditions.checkState(theDatabaseProduct.dbType == dbt);
Review Comment:
I was trying to understand why this code would have passed before my change
and I think I figure it out. I had been seeing this error:
```
Caused by: java.lang.IllegalStateException
at
org.apache.hive.com.google.common.base.Preconditions.checkState(Preconditions.java:159)
at
org.apache.hadoop.hive.metastore.DatabaseProduct.determineDatabaseProduct(DatabaseProduct.java:81)
```
I hit this error because at runtime it passes through the
**DatabaseProduct.determineDatabaseProduct** more than once. The first time,
it would properly initialize DatabaseProduct with my Db2 subclass but the next
time, it would attempt to validate it and would fail with
**java.lang.IllegalStateException**.
I'm sure that if you modified that test to call **determineDatabaseProduct**
again, the test case would fail without my change. Due to the reasons I've
previously explained and explain again below:
Previously **determineDatabaseProduct** would compare the result of
**getDbType(productName)** with the hard coded **dbt = DbType.CUSTOM;** which
gets set **theDatabaseProduct.dbType = dbt;**
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java#L111
meanwhile getDbType should enter the else block and return **dbt =
DbType.UNDEFINED;**
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java#L147
--
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]