diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java index 023934d9eb24..93f63751cc8b 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java @@ -24,6 +24,7 @@ import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -205,23 +206,28 @@ private static String getColTypeOf(Table tbl, String partKey) { protected static List getColumnTypes(Table tbl, List colNames) { List colTypes = new ArrayList<>(); List cols = tbl.getCols(); - List copyColNames = new ArrayList<>(colNames); - - for (String colName : copyColNames) { - for (FieldSchema col : cols) { - if (colName.equalsIgnoreCase(col.getName())) { - String type = col.getType(); - TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(type); - if (typeInfo.getCategory() != ObjectInspector.Category.PRIMITIVE) { - logTypeWarning(colName, type); - colNames.remove(colName); - } else { - colTypes.add(type); - } + Map colTypeMap = new HashMap<>(); + + for (FieldSchema col : cols) { + colTypeMap.put(col.getName().toLowerCase(), col.getType()); + } + + List primColNames = new ArrayList<>(); + for (String colName : colNames) { + String type = colTypeMap.get(colName.toLowerCase()); + if (type != null) { + TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(type); + if (typeInfo.getCategory() != ObjectInspector.Category.PRIMITIVE) { + logTypeWarning(colName, type); + } else { + primColNames.add(colName); + colTypes.add(type); } } } + colNames.clear(); + colNames.addAll(primColNames); return colTypes; }