This is an automated email from the ASF dual-hosted git repository.
rbalamohan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 77494d2 HIVE-25927: Fix DataWritableReadSupport (#2998)
77494d2 is described below
commit 77494d2c4cb65f71044a7f4adc5ff5178712b88a
Author: rbalamohan <[email protected]>
AuthorDate: Mon Feb 7 06:12:50 2022 +0530
HIVE-25927: Fix DataWritableReadSupport (#2998)
---
.../io/parquet/read/DataWritableReadSupport.java | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
diff --git
a/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/read/DataWritableReadSupport.java
b/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/read/DataWritableReadSupport.java
index 12ce221..6aa6d2e 100644
---
a/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/read/DataWritableReadSupport.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/read/DataWritableReadSupport.java
@@ -91,24 +91,6 @@ public class DataWritableReadSupport extends
ReadSupport<ArrayWritable> {
}
/**
- * Searchs for a fieldName into a parquet GroupType by ignoring string case.
- * GroupType#getType(String fieldName) is case sensitive, so we use this
method.
- *
- * @param groupType Group of field types where to search for fieldName
- * @param fieldName The field what we are searching
- * @return The Type object of the field found; null otherwise.
- */
- private static Type getFieldTypeIgnoreCase(GroupType groupType, String
fieldName) {
- for (Type type : groupType.getFields()) {
- if (type.getName().equalsIgnoreCase(fieldName)) {
- return type;
- }
- }
-
- return null;
- }
-
- /**
* Searchs column names by name on a given Parquet schema, and returns its
corresponded
* Parquet schema types.
*
@@ -121,11 +103,13 @@ public class DataWritableReadSupport extends
ReadSupport<ArrayWritable> {
List<Type> schemaTypes = new ArrayList<Type>();
ListIterator<String> columnIterator = colNames.listIterator();
+ Map<String, Type> schemaTypeMap = new HashMap<>();
+ schema.getFields().forEach(t ->
schemaTypeMap.put(t.getName().toLowerCase(), t));
while (columnIterator.hasNext()) {
TypeInfo colType = colTypes.get(columnIterator.nextIndex());
String colName = columnIterator.next();
- Type fieldType = getFieldTypeIgnoreCase(schema, colName);
+ Type fieldType = schemaTypeMap.get(colName.toLowerCase());
if (fieldType == null) {
schemaTypes.add(Types.optional(PrimitiveTypeName.BINARY).named(colName));
} else {