You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "voonhous (via GitHub)" <gi...@apache.org> on 2023/09/20 06:02:20 UTC

[GitHub] [hudi] voonhous opened a new pull request, #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

voonhous opened a new pull request, #9752:
URL: https://github.com/apache/hudi/pull/9752

   ### Change Logs
   
   Spark3.1 uses Avro 1.8.2, where Avro schema resolution on any types that are allowed to have defined namespaces are strictly-matched. i.e. fields are resolved using their fully qualified name. 
   
   This means that namespaces must match-up for reader and writer schema. However, when ALTER-TABLE-NAME-DLL is performed, the tableName in hoodie.properties is changed. The Avro schema that is generated is from the requiredSchema struct is hence different for both reader and writer schema (although the field names and types are the same).
   
   This will lead to read errors, when there are log files when performing ALTER-TABLE-NAME-DLL.
   
   ### Impact
   
   Fixes read issues when ALTER-TABLE-RENAME-DDL is performed when there are LOG files in the table.
   
   ### Risk level (write none, low medium or high below)
   
   _If medium or high, explain what verification was done to mitigate the risks._
   
   ### Documentation Update
   
   _Describe any necessary documentation update if there is any new feature, config, or user-facing change_
   
   - _The config description must be updated if new configs are added or the default value of the configs are changed_
   - _Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
     ticket number here and follow the [instruction](https://hudi.apache.org/contribute/developer-setup#website) to make
     changes to the website._
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Change Logs and Impact were stated clearly
   - [x] Adequate tests were added if applicable
   - [ ] CI passed
   


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1727082397

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d76e45696d4988dbe1629a251f878381d1e525b Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1727485551

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d76e45696d4988dbe1629a251f878381d1e525b Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] yihua commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1732657971

   Should the schema generation of `ALTER TABLE` DDL be fixed instead to make sure the namespace is consistent?


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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1777997252

   > Seems we have plan to mograte to avro above 1.8.2 right cc @yihua ~
   The Avro dependency version is tied to Spark version and Avro 1.8.2 is tied to Spark 3.1.


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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1816010495

   Another way around this is to block alter table rename for MOR tables on Spark3.1. 
   
   For the error message, we can just point them to an FAQ page on the docsite or a HUDI PR, where we can document the restriction set in place due to dependency restrictions? 
   
   Is such a solution cleaner?


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1727500049

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d76e45696d4988dbe1629a251f878381d1e525b Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045) 
   * 4388263c6e932c6daa3fda8e247a50a00a6a46e4 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1728905717

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050",
       "triggerID" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20063",
       "triggerID" : "1728662134",
       "triggerType" : "MANUAL"
     } ]
   }-->
   ## CI report:
   
   * 4388263c6e932c6daa3fda8e247a50a00a6a46e4 Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050) Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20063) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1727877693

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050",
       "triggerID" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 4388263c6e932c6daa3fda8e247a50a00a6a46e4 Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] danny0405 commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1736631259

   Seems we have plan to mograte to avro above 1.8.2 right cc @yihua ~


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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua commented on code in PR #9752:
URL: https://github.com/apache/hudi/pull/9752#discussion_r1370788996


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieDataBlock.java:
##########
@@ -115,6 +114,35 @@ public byte[] getContentBytes() throws IOException {
     return serializeRecords(records.get());
   }
 
+  private Schema getReaderSchema(Option<Schema> readerSchemaOpt) {
+    Schema writerSchema = getWriterSchema(super.getLogBlockHeader());
+    // If no reader-schema has been provided assume writer-schema as one
+    if (!readerSchemaOpt.isPresent()) {
+      return writerSchema;
+    }
+
+    // Handle table renames when there are still log files
+    Schema readerSchema = readerSchemaOpt.get();
+    if (isHandleDifferingNamespaceRequired(readerSchema, writerSchema)) {
+      return writerSchema;
+    } else {
+      return readerSchema;
+    }
+  }
+
+  /**
+   * Spark3.1 uses avro:1.8.2, which matches fields by their fully qualified name. If namespaces are differs, reads will fail for fields that have the same name and type, but differing name(spaces).
+   * Such cases can arise when an ALTER-TABLE-RENAME ddl is performed.
+   *
+   * @param readerSchema the reader schema
+   * @param writerSchema the writer schema
+   * @return boolean if handling of differing namespaces between reader and writer schema are required
+   */
+  private static boolean isHandleDifferingNamespaceRequired(Schema readerSchema, Schema writerSchema) {
+    return readerSchema.getClass().getPackage().getImplementationVersion().compareTo("1.8.2") <= 0
+        && !readerSchema.getName().equals(writerSchema.getName());
+  }

Review Comment:
   The fix works.  But I'm thinking at this layer of reading log files, such details should not be exposed.  It's better to fix the schema generation in ALTER-TABLE-RENAME DDL to have consistent namespaces, or resolve the schema's namespace on upper layers, e.g., `TableSchemaResolver`.  And the schema namespace should not change across Hudi commits.



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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1728689563

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050",
       "triggerID" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20063",
       "triggerID" : "1728662134",
       "triggerType" : "MANUAL"
     } ]
   }-->
   ## CI report:
   
   * 4388263c6e932c6daa3fda8e247a50a00a6a46e4 Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050) Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20063) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua closed pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1
URL: https://github.com/apache/hudi/pull/9752


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1727072029

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d76e45696d4988dbe1629a251f878381d1e525b UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] voonhous commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1728662134

   @hudi-bot run azure


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


[GitHub] [hudi] voonhous commented on a diff in pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #9752:
URL: https://github.com/apache/hudi/pull/9752#discussion_r1332380352


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieDataBlock.java:
##########
@@ -115,6 +114,35 @@ public byte[] getContentBytes() throws IOException {
     return serializeRecords(records.get());
   }
 
+  private Schema getReaderSchema(Option<Schema> readerSchemaOpt) {
+    Schema writerSchema = getWriterSchema(super.getLogBlockHeader());
+    // If no reader-schema has been provided assume writer-schema as one
+    if (!readerSchemaOpt.isPresent()) {

Review Comment:
   It's setup here: `org.apache.hudi.HoodieBaseRelation#buildScan`, where the it is usually derived from `org.apache.hudi.HoodieBaseRelation#tableAvroSchema`
   
   



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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "yihua (via GitHub)" <gi...@apache.org>.
yihua commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-2344723886

   > @yihua Another way around this is to block alter table rename for MOR tables on Spark3.1.
   > 
   > For the error message, we can just point them to an FAQ page on the docsite or a HUDI PR, where we can document the restriction set in place due to dependency restrictions?
   > 
   > Is such a solution cleaner?
   
   
   
   > @yihua Another way around this is to block alter table rename for MOR tables on Spark3.1.
   > 
   > For the error message, we can just point them to an FAQ page on the docsite or a HUDI PR, where we can document the restriction set in place due to dependency restrictions?
   > 
   > Is such a solution cleaner?
   
   We can do that.  Given that we've removed the code for integrating Spark 3.2 and below, I'm closing this PR.  Feel free to create a new PR against `branch-0.x` if the fix is still useful.


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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "nsivabalan (via GitHub)" <gi...@apache.org>.
nsivabalan commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1814435899

   hey @yihua and @voonhous : can you folks be able to work on the patch and get it landed. if we want to get this in for 0.14.1, we might want it to be done in a week or two. 


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


Re: [PR] [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1 [hudi]

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #9752:
URL: https://github.com/apache/hudi/pull/9752#discussion_r1371085479


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieDataBlock.java:
##########
@@ -115,6 +114,35 @@ public byte[] getContentBytes() throws IOException {
     return serializeRecords(records.get());
   }
 
+  private Schema getReaderSchema(Option<Schema> readerSchemaOpt) {
+    Schema writerSchema = getWriterSchema(super.getLogBlockHeader());
+    // If no reader-schema has been provided assume writer-schema as one
+    if (!readerSchemaOpt.isPresent()) {
+      return writerSchema;
+    }
+
+    // Handle table renames when there are still log files
+    Schema readerSchema = readerSchemaOpt.get();
+    if (isHandleDifferingNamespaceRequired(readerSchema, writerSchema)) {
+      return writerSchema;
+    } else {
+      return readerSchema;
+    }
+  }
+
+  /**
+   * Spark3.1 uses avro:1.8.2, which matches fields by their fully qualified name. If namespaces are differs, reads will fail for fields that have the same name and type, but differing name(spaces).
+   * Such cases can arise when an ALTER-TABLE-RENAME ddl is performed.
+   *
+   * @param readerSchema the reader schema
+   * @param writerSchema the writer schema
+   * @return boolean if handling of differing namespaces between reader and writer schema are required
+   */
+  private static boolean isHandleDifferingNamespaceRequired(Schema readerSchema, Schema writerSchema) {
+    return readerSchema.getClass().getPackage().getImplementationVersion().compareTo("1.8.2") <= 0
+        && !readerSchema.getName().equals(writerSchema.getName());
+  }

Review Comment:
   Agreed, the fix here was written with  backwards compatibility in mind. For tables that already have log files that were written in a certain format + namespace and have yet to be compacted, it is not realistic to modify those name spaces block by block. 
   
   Given that this is an avro internal issue for lower avro version, and will only happen when performing merge. I thought it will be appropriate to put it here while reading log files.
   
   There are a few ways to fix this like you mentioned and they are:
   
   1. `ALTER-TABLE-RENAME-DDL` will rename the hive table name, but will not perform any internal renames. i.e. `hoodie.properties` will not be re-written, schema will hence be consistent.
   2. Block `ALTER-TABLE-RENAME-DDL` if there are uncompacted log files; ALTER-TABLE-RENAME-DDL will be IO intensive, need to scan through all latest file slices to see if there are any uncompacted filegroups. log file list > 0 (akin to running a plan-compaction execution, and if compaction operations is not empty, we will reject the rename)
   3. Fix it while reading as seen in the fix here (code is ugly and we are coupling business logic + with dependency version)



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


[GitHub] [hudi] voonhous commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1732811642

   > Should the schema generation of `ALTER TABLE` DDL be fixed instead to make sure the namespace is consistent?
   
   @yihua Apologies for the late reply. Uhm namespace inconsistencies between block and generated avro-schema will only be an issue if 
   1. the table is not compacted
   2. an ALTER-TABLE-RENAME DDL is performed on the table.
   3. subsequent reads are performed on Spark3.1 which uses Avro:1.8.2
   
   Avro:1.8.2 matches fields that by fully qualified names. However, avro versions above a certain version does not. 
   
   
   Attached are the screenshots from the avro docs.
   
   # Avro:1.8.2 (used by Spark3.1)
   
   https://avro.apache.org/docs/1.8.2/spec.html#Schema+Resolution
   
   <img width="851" alt="image" src="https://github.com/apache/hudi/assets/6312314/d2f434de-fce3-459b-a91e-829eb835cdad">
   
   
   # Avro:1.10.2 (used by Spark3.2)
   
   https://avro.apache.org/docs/1.10.2/spec.html#Schema+Resolution
   
   <img width="830" alt="image" src="https://github.com/apache/hudi/assets/6312314/eeaddf35-e3af-4d25-8b43-992538741667">
   


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


[GitHub] [hudi] hudi-bot commented on pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #9752:
URL: https://github.com/apache/hudi/pull/9752#issuecomment-1727564269

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045",
       "triggerID" : "5d76e45696d4988dbe1629a251f878381d1e525b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050",
       "triggerID" : "4388263c6e932c6daa3fda8e247a50a00a6a46e4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5d76e45696d4988dbe1629a251f878381d1e525b Azure: [FAILURE](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20045) 
   * 4388263c6e932c6daa3fda8e247a50a00a6a46e4 Azure: [PENDING](https://dev.azure.com/apache-hudi-ci-org/785b6ef4-2f42-4a89-8f0e-5f0d7039a0cc/_build/results?buildId=20050) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


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


[GitHub] [hudi] danny0405 commented on a diff in pull request #9752: [HUDI-6877] Fix avro read issue after ALTER TABLE RENAME DDL on Spark3_1

Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #9752:
URL: https://github.com/apache/hudi/pull/9752#discussion_r1332361159


##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieDataBlock.java:
##########
@@ -115,6 +114,35 @@ public byte[] getContentBytes() throws IOException {
     return serializeRecords(records.get());
   }
 
+  private Schema getReaderSchema(Option<Schema> readerSchemaOpt) {
+    Schema writerSchema = getWriterSchema(super.getLogBlockHeader());
+    // If no reader-schema has been provided assume writer-schema as one
+    if (!readerSchemaOpt.isPresent()) {

Review Comment:
   Could you clarify when the reader schema is setup?



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