You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/11/17 12:43:26 UTC

[GitHub] [hudi] xiarixiaoyao commented on a diff in pull request #6358: [HUDI-4588][HUDI-4472] Addressing schema handling issues in the write path

xiarixiaoyao commented on code in PR #6358:
URL: https://github.com/apache/hudi/pull/6358#discussion_r1025141129


##########
hudi-common/src/main/java/org/apache/hudi/avro/AvroSchemaUtils.java:
##########
@@ -31,6 +31,31 @@ public class AvroSchemaUtils {
 
   private AvroSchemaUtils() {}
 
+  /**
+   * Generates fully-qualified name for the Avro's schema based on the Table's name
+   *
+   * NOTE: PLEASE READ CAREFULLY BEFORE CHANGING
+   *       This method should not change for compatibility reasons as older versions
+   *       of Avro might be comparing fully-qualified names rather than just the record
+   *       names
+   */
+  public static String getAvroRecordQualifiedName(String tableName) {
+    String sanitizedTableName = HoodieAvroUtils.sanitizeName(tableName);
+    return "hoodie." + sanitizedTableName + "." + sanitizedTableName + "_record";
+  }
+
+  // TODO java-doc, test
+  public static boolean isProjectionOf(Schema sourceSchema, Schema targetSchema) {
+    for (Schema.Field targetField : targetSchema.getFields()) {
+      Schema.Field sourceField = sourceSchema.getField(targetField.name());

Review Comment:
   avro1.10    getField will throw exception instead of return null,
   ```
     public Field getField(String fieldname) {
       throw new AvroRuntimeException("Not a record: " + this);
     }
   ```



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org