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: [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]

Reply via email to