Skip to content

Commit

Permalink
HIVE-11964: RelOptHiveTable.hiveColStatsMap might contain mismatched …
Browse files Browse the repository at this point in the history
…column stats (Chaoyu Tang, reviewed by Laljo John Pullokkaran)
  • Loading branch information
chaoyu-tang committed Sep 30, 2015
1 parent 1cb3073 commit 1f08789
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ private void updateColStats(Set<Integer> projIndxLst, boolean allowNullColumnFor
setOfFiledCols.removeAll(setOfObtainedColStats);

colNamesFailedStats.addAll(setOfFiledCols);
} else {
// Column stats in hiveColStats might not be in the same order as the columns in
// nonPartColNamesThatRqrStats. reorder hiveColStats so we can build hiveColStatsMap
// using nonPartColIndxsThatRqrStats as below
Map<String, ColStatistics> columnStatsMap =
new HashMap<String, ColStatistics>(hiveColStats.size());
for (ColStatistics cs : hiveColStats) {
columnStatsMap.put(cs.getColumnName(), cs);
}
hiveColStats.clear();
for (String colName : nonPartColNamesThatRqrStats) {
hiveColStats.add(columnStatsMap.get(colName));
}
}
} else {
// 2.2 Obtain col stats for partitioned table.
Expand Down Expand Up @@ -349,6 +362,8 @@ private void updateColStats(Set<Integer> projIndxLst, boolean allowNullColumnFor

if (hiveColStats != null && hiveColStats.size() == nonPartColNamesThatRqrStats.size()) {
for (int i = 0; i < hiveColStats.size(); i++) {
// the columns in nonPartColIndxsThatRqrStats/nonPartColNamesThatRqrStats/hiveColStats
// are in same order
hiveColStatsMap.put(nonPartColIndxsThatRqrStats.get(i), hiveColStats.get(i));
}
}
Expand Down

0 comments on commit 1f08789

Please sign in to comment.