You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/07/24 00:50:50 UTC

[GitHub] [incubator-pinot] siddharthteotia commented on a change in pull request #5746: Fix code to correctly extract value of multi-value column from avro file

siddharthteotia commented on a change in pull request #5746:
URL: https://github.com/apache/incubator-pinot/pull/5746#discussion_r459804013



##########
File path: pinot-plugins/pinot-input-format/pinot-avro-base/src/main/java/org/apache/pinot/plugin/inputformat/avro/AvroUtils.java
##########
@@ -353,16 +353,6 @@ public static Object handleMap(Map map) {
    * Handles the conversion of every field of the GenericRecord
    */
   private static Object handleGenericRecord(GenericData.Record record) {
-    List<Field> fields = record.getSchema().getFields();
-    if (fields.isEmpty()) {
-      return null;
-    }
-
-    Map<Object, Object> convertedMap = new HashMap<>();
-    for (Field field : fields) {
-      String fieldName = field.name();
-      convertedMap.put(fieldName, convert(record.get(fieldName)));
-    }
-    return convertedMap;
+    return record.get(0);

Review comment:
       If GenericData.Record is supposed imply SV, then what is the distinction between the last two branches of this code
   
   `public static Object convert(Object value) {
       if (value == null) {
         return null;
       }
       Object convertedValue;
       if (value instanceof Collection) {
         convertedValue = handleMultiValue((Collection) value);
       } else if (value instanceof Map) {
         convertedValue = handleMap((Map) value);
       } else if(value instanceof GenericData.Record) {
         convertedValue = handleGenericRecord((GenericData.Record) value);
       } else {
         convertedValue = RecordReaderUtils.convertSingleValue(value);
       }
       return convertedValue;
     }`

##########
File path: pinot-plugins/pinot-input-format/pinot-avro-base/src/main/java/org/apache/pinot/plugin/inputformat/avro/AvroUtils.java
##########
@@ -353,16 +353,6 @@ public static Object handleMap(Map map) {
    * Handles the conversion of every field of the GenericRecord
    */
   private static Object handleGenericRecord(GenericData.Record record) {
-    List<Field> fields = record.getSchema().getFields();
-    if (fields.isEmpty()) {
-      return null;
-    }
-
-    Map<Object, Object> convertedMap = new HashMap<>();
-    for (Field field : fields) {
-      String fieldName = field.name();
-      convertedMap.put(fieldName, convert(record.get(fieldName)));
-    }
-    return convertedMap;
+    return record.get(0);

Review comment:
       If GenericData.Record is supposed imply SV, then what is the distinction between the last two branches of this code
   
   `public static Object convert(Object value) {
       if (value == null) {
         return null;
       }
       Object convertedValue;
       if (value instanceof Collection) {
         convertedValue = handleMultiValue((Collection) value);
       } else if (value instanceof Map) {
         convertedValue = handleMap((Map) value);
       } else if(value instanceof GenericData.Record) {
         convertedValue = handleGenericRecord((GenericData.Record) value);
       } else {
         convertedValue = RecordReaderUtils.convertSingleValue(value);
       }
       return convertedValue;
     }```




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org