diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java index b98b4b4005..5e2922fb5f 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -9052,21 +9052,28 @@ public AggrStats get_aggr_stats_for(String catName, String dbName, String tblNam return null; } - MTable table = getMTable(catName, dbName, tblName); + Table table = getTable(catName, dbName, tblName); boolean isTxn = TxnUtils.isTransactionalTable(table.getParameters()); if (isTxn && !areTxnStatsSupported) { return null; } + GetPartitionsFilterSpec fs = new GetPartitionsFilterSpec(); + fs.setFilterMode(PartitionFilterMode.BY_NAMES); + fs.setFilters(partNames); + GetPartitionsProjectionSpec ps = new GetPartitionsProjectionSpec(); + ps.setIncludeParamKeyPattern(StatsSetupConst.COLUMN_STATS_ACCURATE + '%'); + ps.setFieldList(Lists.newArrayList("writeId", "parameters", "values")); + List parts = getPartitionSpecsByFilterAndProjection(table, ps, fs); + // List parts = getPartitionsByNames(catName, dbName, tblName, partNames); // Loop through the given "partNames" list // checking isolation-level-compliance of each partition column stats. - for (String partName : partNames) { - MPartition mpart = getMPartition( - catName, dbName, tblName, Warehouse.getPartValuesFromPartName(partName)); - if (!isCurrentStatsValidForTheQuery(mpart, writeIdList, false)) { - LOG.debug("The current metastore transactional partition column statistics " + - "for " + dbName + "." + tblName + "." + mpart.getPartitionName() + " is not valid " + - "for the current query."); + for (Partition part : parts) { + + if (!isCurrentStatsValidForTheQuery(part, part.getWriteId(), writeIdList, false)) { + String partName = Warehouse.makePartName(table.getPartitionKeys(), part.getValues()); + LOG.debug("The current metastore transactional partition column statistics for " + dbName + + "." + tblName + "." + partName + " is not valid for the current query"); return null; } }