pvary commented on code in PR #3053:
URL: https://github.com/apache/hive/pull/3053#discussion_r845256354


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java:
##########
@@ -422,21 +413,46 @@ void findUnknownPartitions(Table table, Set<Path> 
partPaths, byte[] filterExp,
       }
       allPartDirs = partDirs;
     }
-    // don't want the table dir
-    allPartDirs.remove(tablePath);
-
-    // remove the partition paths we know about
-    allPartDirs.removeAll(partPaths);
-
     Set<String> partColNames = Sets.newHashSet();
     for(FieldSchema fSchema : getPartCols(table)) {
       partColNames.add(fSchema.getName());
     }
 
     Map<String, String> partitionColToTypeMap = 
getPartitionColtoTypeMap(table.getPartitionKeys());
+
+    Set<Path> correctPartPathsInMS = new HashSet<>(partPathsInMS);
+    // remove partition paths in partPathsInMS, to getPartitionsNotOnFs
+    partPathsInMS.removeAll(allPartDirs);
+    FileSystem fs = tablePath.getFileSystem(conf);
+    // There can be edge case where user can define partition directory 
outside of table directory
+    // to avoid eviction of such partitions
+    // we check for partition path not exists and add to result for 
getPartitionsNotOnFs.
+    for (Path partPath : partPathsInMS) {
+      CheckResult.PartitionResult pr = new CheckResult.PartitionResult();
+      pr.setTableName(table.getTableName());
+      pr.setPartitionName(getPartitionName(fs.makeQualified(tablePath),
+              partPath, partColNames, partitionColToTypeMap));
+      if (!fs.exists(partPath)) {
+        result.getPartitionsNotOnFs().add(pr);
+        correctPartPathsInMS.remove(partPath);
+      }
+    }
+    for (Path partPath : correctPartPathsInMS) {
+      CheckResult.PartitionResult pr = new CheckResult.PartitionResult();
+      pr.setTableName(table.getTableName());
+      pr.setPartitionName(getPartitionName(fs.makeQualified(tablePath),
+              partPath, partColNames, partitionColToTypeMap));
+      result.getCorrectPartitions().add(pr);
+    }
+
+    // don't want the table dir
+    allPartDirs.remove(tablePath);
+
+    // remove the partition paths we know about
+    allPartDirs.removeAll(partPaths);

Review Comment:
   Does allPartDirs contain non-full path objects? Do we need them there?



-- 
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