[ 
https://issues.apache.org/jira/browse/HIVE-26062?focusedWorklogId=747645&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-747645
 ]

ASF GitHub Bot logged work on HIVE-26062:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Mar/22 07:40
            Start Date: 25/Mar/22 07:40
    Worklog Time Spent: 10m 
      Work Description: pvary commented on a change in pull request #3138:
URL: https://github.com/apache/hive/pull/3138#discussion_r835020859



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreSchemaInfo.java
##########
@@ -205,19 +206,32 @@ public boolean isVersionCompatible(String hiveVersion, 
String dbVersion) {
       return false;
     }
 
-    for (int i = 0; i < dbVerParts.length; i++) {
-      int dbVerPart = Integer.parseInt(dbVerParts[i]);
-      int hiveVerPart = Integer.parseInt(hiveVerParts[i]);
-      if (dbVerPart > hiveVerPart) {
-        return true;
-      } else if (dbVerPart < hiveVerPart) {
-        return false;
-      } else {
-        continue; // compare next part
+    int i = 0;

Review comment:
       This makes me nervous 😄 
   Why do we have to move around the declaration of `i`?
   
   Maybe the code would be easier to read this way:
   ```
   hiveVerParts = hiveVersion.split("\\.|-");
   dbVerParts = dbVersion.split("\\.|-");
   for (int i; i < Math.min(hiveVerParts.length, dbVerParts.length); i++) {
     int compare = compareVersion(dbVerParts[i], hiveVerParts[i]);
     if (compare != 0) {
       return compare > 0;
     }
   }
   
   // This is always false, as we already checked that hiveVersion and 
dbVersions are different 
   return hiveVerParts.length == dbVerParts.length;
   ```




-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 747645)
    Time Spent: 1h 10m  (was: 1h)

> Make sure that running 4.0.0-alpha-2 above 4.0.0-alpha-1 HMS DB reports the 
> correct error
> -----------------------------------------------------------------------------------------
>
>                 Key: HIVE-26062
>                 URL: https://issues.apache.org/jira/browse/HIVE-26062
>             Project: Hive
>          Issue Type: Task
>            Reporter: Peter Vary
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> When comparing expected and actual HMS DB versions the code has problems with 
> parsing  {{alpha-1}}. We should make sure that the appropriate error message 
> is returned to the customer instead of a {{NumberFormatException}}.
> Currently we have this, and we might just want to return {{false}} if there 
> is no exact match:
> {code}
> java.lang.NumberFormatException: For input string: "0-alpha-1"
> at 
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> at java.lang.Integer.parseInt(Integer.java:580)
> at java.lang.Integer.parseInt(Integer.java:615)
> at 
> org.apache.hadoop.hive.metastore.MetaStoreSchemaInfo.isVersionCompatible(MetaStoreSchemaInfo.java:210)
> at 
> org.apache.hadoop.hive.metastore.ObjectStore.checkSchema(ObjectStore.java:10870)
> at 
> org.apache.hadoop.hive.metastore.ObjectStore.verifySchema(ObjectStore.java:10839)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:97)
> at com.sun.proxy.$Proxy28.verifySchema(Unknown Source)
> at 
> org.apache.hadoop.hive.metastore.HMSHandler.getMSForConf(HMSHandler.java:610)
> at org.apache.hadoop.hive.metastore.HMSHandler.getMS(HMSHandler.java:602)
> at 
> org.apache.hadoop.hive.metastore.HMSHandler.createDefaultDB(HMSHandler.java:686)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to