deniskuzZ commented on a change in pull request #1834:
URL: https://github.com/apache/hive/pull/1834#discussion_r555698743



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/TaskCompiler.java
##########
@@ -412,12 +419,27 @@ private String extractTableFullName(StatsTask tsk) throws 
SemanticException {
         .getInputFormatClass();
     Table table = tableScan.getConf().getTableMetadata();
     List<Partition> partitions = new ArrayList<>();
+    AcidUtils.TableSnapshot tableSnapshot = null;
+    if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_STATS_TASK_OPTIMIZE)) 
{
+      tableSnapshot = AcidUtils.getTableSnapshot(conf, table, true);
+    }
     if (table.isPartitioned()) {
-      
partitions.addAll(parseContext.getPrunedPartitions(tableScan).getPartitions());
-      for (Partition partn : partitions) {
+      for (Partition partn : 
parseContext.getPrunedPartitions(tableScan).getPartitions()) {
         LOG.trace("adding part: " + partn);
+        if (tableSnapshot != null && 
ColStatsProcessor.canSkipStatsGeneration(table.getDbName(), 
table.getTableName(),
+                FileUtils.makePartName(table.getPartColNames(), 
partn.getTPartition().getValues()),
+                partn.getTPartition().getWriteId(), 
tableSnapshot.getValidWriteIdList())) {
+          continue;
+        }
+        partitions.add(partn);
         outputs.add(new WriteEntity(partn, WriteEntity.WriteType.DDL_NO_LOCK));
       }
+      if (partitions.isEmpty()) {
+        return null;

Review comment:
       could we refactor to return Optional here?




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

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