KazydubB commented on a change in pull request #1829: DRILL-7096: Develop
vector for canonical Map<K,V>
URL: https://github.com/apache/drill/pull/1829#discussion_r310163995
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet2/DrillParquetReader.java
##########
@@ -175,6 +183,38 @@ private static MessageType getProjection(MessageType
schema,
return projection;
}
+ /**
+ * Get type from the supplied {@code type} corresponding to given {@code
segment}.
+ * @param type type to extract field corresponding to segment
+ * @param segment segment which type will be returned
+ * @return type corresponding to the {@code segment} or {@code null} if
there is no field found in {@code type}.
+ */
+ private static Type getType(Type type, PathSegment segment) {
+ Type result = null;
+ if (type != null && !type.isPrimitive()) {
+ GroupType groupType = type.asGroupType();
+ if (segment.isNamed()) {
+ boolean found = false;
+ String fieldName = segment.getNameSegment().getPath();
+ for (Type field : groupType.getFields()) {
+ if (field.getName().equalsIgnoreCase(fieldName)) {
+ fieldName = field.getName();
+ found = true;
+ break;
+ }
+ }
+ result = found ? groupType.getType(fieldName) : null;
+ } else {
+ // the segment is array index
+ if (groupType.getOriginalType() == OriginalType.LIST) {
+ // get element type of the list
+ result = groupType.getType(0).asGroupType().getType(0);
+ }
+ }
+ }
+ return result;
Review comment:
yes, it is OK.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services