tanishq-chugh commented on code in PR #6443:
URL: https://github.com/apache/hive/pull/6443#discussion_r3159116400
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java:
##########
@@ -217,27 +218,32 @@ private static String getColTypeOf(Table tbl, String
partKey) {
throw new RuntimeException("Unknown partition key : " + partKey);
}
- protected static List<String> getColumnTypes(Table tbl, List<String>
colNames) {
+ protected static List<String> getColumnTypesByName(Table tbl, List<String>
colNames) {
List<String> colTypes = new ArrayList<>();
List<FieldSchema> cols = tbl.getCols();
- List<String> 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);
- boolean isSupported =
ColumnStatsAutoGatherContext.isColumnSupported(typeInfo.getCategory(), () ->
typeInfo);
- if (!isSupported) {
- logTypeWarning(colName, type);
- colNames.remove(colName);
- } else {
- colTypes.add(type);
- }
+ Map<String, String> colTypeMap = new HashMap<>();
+
+ for (FieldSchema col : cols) {
+ colTypeMap.put(col.getName().toLowerCase(), col.getType());
+ }
+
+ List<String> primColNames = new ArrayList<>();
+ for (String colName : colNames) {
+ String type = colTypeMap.get(colName.toLowerCase());
+ if (type != null) {
+ TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(type);
+ boolean isSupported =
ColumnStatsAutoGatherContext.isColumnSupported(typeInfo.getCategory(), () ->
typeInfo);
+ if (!isSupported) {
+ logTypeWarning(colName, type);
+ } else {
+ primColNames.add(colName);
+ colTypes.add(type);
}
}
}
+ colNames.clear();
+ colNames.addAll(primColNames);
Review Comment:
Yes, the code has been updated such that modifying this argument is avoided,
in commit -
[84d81f9](https://github.com/apache/hive/pull/6443/commits/84d81f933cf7ecd8112293895c3d3997cc7292f1)
--
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]