danny0405 commented on code in PR #8054:
URL: https://github.com/apache/hudi/pull/8054#discussion_r1118459723


##########
hudi-sync/hudi-sync-common/src/main/java/org/apache/hudi/sync/common/util/Parquet2SparkSchemaUtils.java:
##########
@@ -34,25 +38,43 @@
 public class Parquet2SparkSchemaUtils {
 
   public static String convertToSparkSchemaJson(GroupType parquetSchema) {
+    return convertToSparkSchemaJson(parquetSchema, Collections.emptyMap());
+  }
+
+  public static String convertToSparkSchemaJson(GroupType parquetSchema, 
Map<String, String> commentMap) {
     String fieldsJsonString = parquetSchema.getFields().stream().map(field -> {
       switch (field.getRepetition()) {
         case OPTIONAL:
           return "{\"name\":\"" + field.getName() + "\",\"type\":" + 
convertFieldType(field)
-                  + ",\"nullable\":true,\"metadata\":{}}";
+              + ",\"nullable\":true,\"metadata\":{" + 
getCommentStr(commentMap.get(field.getName())) + "}}";
         case REQUIRED:
           return "{\"name\":\"" + field.getName() + "\",\"type\":" + 
convertFieldType(field)
-                  + ",\"nullable\":false,\"metadata\":{}}";
+              + ",\"nullable\":false,\"metadata\":{" + 
getCommentStr(commentMap.get(field.getName())) + "}}";
         case REPEATED:
           String arrayType = arrayType(field, false);
           return "{\"name\":\"" + field.getName() + "\",\"type\":" + arrayType
-                  + ",\"nullable\":false,\"metadata\":{}}";
+              + ",\"nullable\":false,\"metadata\":{" + 
getCommentStr(commentMap.get(field.getName())) + "}}";
         default:
           throw new UnsupportedOperationException("Unsupport convert " + field 
+ " to spark sql type");
       }
     }).reduce((a, b) -> a + "," + b).orElse("");
     return "{\"type\":\"struct\",\"fields\":[" + fieldsJsonString + "]}";
   }
 
+  /**
+   * get comment
+   *
+   * @param comment
+   * @return
+   */
+  private static String getCommentStr(String comment) {
+    String result = "";

Review Comment:
   What are these spark changes used for?



-- 
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]

Reply via email to