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 2026/07/15 09:00:37 UTC

[PR] 19279 mdt hfile log deltas [hudi]

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

   ### Describe the issue this Pull Request addresses
   
   <!-- Either describe the issue inline here with motivation behind the changes 
        (or) link to an issue by including `Closes #<issue-number>` for context. 
        If this PR includes changes to the storage format, public APIs,
        or has breaking changes, use `!` (e.g., feat!: ...) -->
   
   ### Summary and Changelog
   
   <!-- Short, plain-English summary of what users gain or what changed in behavior.
        Followed by a detailed log of all the changes. Highlight if any code was copied. -->
   
   ### Impact
   
   <!-- Describe any public API or user-facing feature change or any performance impact. -->
   
   ### Risk Level
   
   <!-- Accepted values: none, low, medium or high. Other than `none`, explain the risk.
        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. If not, put "none".
   
   - 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 follow the 
     [instruction](https://hudi.apache.org/contribute/developer-setup#website) to make changes to the website. -->
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Enough context is provided in the sections above
   - [ ] Adequate tests were added if applicable
   


-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/main/java/io/trino/plugin/hudi/query/HudiSnapshotDirectoryLister.java:
##########
@@ -54,9 +58,22 @@ public HudiSnapshotDirectoryLister(
         this.lazyFileSystemView = Lazy.lazily(() -> {
             HoodieTimer timer = HoodieTimer.start();
             HoodieTableMetaClient metaClient = tableHandle.getMetaClient();
-            HoodieTableFileSystemView fileSystemView = getFileSystemView(lazyTableMetadata.get(), metaClient);
-            if (enableMetadataTable) {
-                fileSystemView.loadAllPartitions();
+            HoodieTableFileSystemView fileSystemView = null;
+            try {
+                fileSystemView = getFileSystemView(lazyTableMetadata.get(), metaClient);
+                if (enableMetadataTable) {
+                    fileSystemView.loadAllPartitions();
+                }
+            }
+            catch (Exception e) {
+                // A failure here is a metadata-table read failure (the metastore/table itself is
+                // fine), so fall back to direct file listing instead of failing the query.
+                if (fileSystemView != null && !fileSystemView.isClosed()) {
+                    fileSystemView.close();

Review Comment:
   Dropped. Left a comment on why the failed view must stay unclosed -- closing it would take the shared HoodieTableMetadata behind lazyTableMetadata down with it.



##########
hudi-trino/src/main/java/io/trino/plugin/hudi/query/HudiSnapshotDirectoryLister.java:
##########
@@ -67,6 +84,22 @@ public HudiSnapshotDirectoryLister(
                 IndexSupportFactory.createIndexSupport(tableHandle, lazyMetaClient, lazyTableMetadata, tableHandle.getRegularPredicates(), session) : Optional.empty();
     }
 
+    /**
+     * Builds a file system view that lists files directly from storage, bypassing the metadata table.
+     * Used as the fallback when the metadata-table-backed view cannot be loaded (e.g. an MDT read
+     * failure); it lists lazily per partition, so no {@code loadAllPartitions()} here.
+     */
+    private static HoodieTableFileSystemView createDirectListingFileSystemView(HoodieTableMetaClient metaClient)

Review Comment:
   Done. The fallback is now a single fileListingBasedFileSystemView call with the same completed-commits timeline HudiUtil.getFileSystemView uses.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   @wombatu-kun This is ready for review, thank you!


-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   ## [Codecov](https://app.codecov.io/gh/apache/hudi/pull/19298?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 75.09%. Comparing base ([`e37bfb5`](https://app.codecov.io/gh/apache/hudi/commit/e37bfb5e4766109f05f83a6d39e5b9d31b549451?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8ddb323`](https://app.codecov.io/gh/apache/hudi/commit/8ddb323e74f8e80c1f94524daa7b7aa89da0b557?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 11 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #19298      +/-   ##
   ============================================
   - Coverage     75.55%   75.09%   -0.46%     
   + Complexity    32657    32519     -138     
   ============================================
     Files          2574     2576       +2     
     Lines        142995   143146     +151     
     Branches      17530    17544      +14     
   ============================================
   - Hits         108038   107498     -540     
   - Misses        26922    27609     +687     
   - Partials       8035     8039       +4     
   ```
   
   | [Components](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hudi-common](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `82.18% <ø> (-0.09%)` | :arrow_down: |
   | [hudi-client](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.69% <51.94%> (-0.12%)` | :arrow_down: |
   | [hudi-flink](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `80.91% <73.83%> (-3.07%)` | :arrow_down: |
   | [hudi-spark-datasource](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.34% <ø> (ø)` | |
   | [hudi-utilities](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `71.20% <ø> (-0.03%)` | :arrow_down: |
   | [hudi-cli](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `15.32% <ø> (ø)` | |
   | [hudi-hadoop](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `63.49% <ø> (ø)` | |
   | [hudi-sync](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.30% <0.00%> (-0.38%)` | :arrow_down: |
   | [hudi-io](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `79.55% <90.90%> (-0.02%)` | :arrow_down: |
   | [hudi-timeline-service](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `84.52% <ø> (ø)` | |
   | [hudi-cloud](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `64.00% <ø> (ø)` | |
   | [hudi-kafka-connect](https://app.codecov.io/gh/apache/hudi/pull/19298/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.20% <ø> (ø)` | |
   
   | [Flag](https://app.codecov.io/gh/apache/hudi/pull/19298/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [flink-integration-tests](https://app.codecov.io/gh/apache/hudi/pull/19298/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.89% <ø> (-11.95%)` | :arrow_down: |
   | [hadoop-mr-java-client](https://app.codecov.io/gh/apache/hudi/pull/19298/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `43.41% <ø> (+0.03%)` | :arrow_up: |
   | [spark-client-hadoop-common](https://app.codecov.io/gh/apache/hudi/pull/19298/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `48.68% <ø> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   [see 70 files with indirect coverage changes](https://app.codecov.io/gh/apache/hudi/pull/19298/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

Posted by "wombatu-kun (via GitHub)" <gi...@apache.org>.
wombatu-kun commented on code in PR #19298:
URL: https://github.com/apache/hudi/pull/19298#discussion_r3691325921


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's

Review Comment:
   Only 7 of the 21 zip fixtures set `compact.max.delta.commits=1`, and `hudi_trips_cow_v8` and `hudi_cow_table_with_field_names_in_caps` both ship ~14KB data-bearing MDT log deltas with no compaction instant, so "always freshly compacted" is not why this escaped. Was the real reason that the paths reading them - col-stats skipping and the MDT partition listing - already swallowed the failure, leaving only partition-stats pruning unguarded?



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {
+            return;
+        }
+        throw new IllegalStateException(
+                "Metadata table of " + CORRUPTED_TABLE_NAME + " is still readable (partitions: " + partitions
+                        + "); corruptMetadataLogFiles no longer lands on the HFile trailer fields");
+    }
+
+    private static void writeTable(Path tablePath, String tableName)
+    {
+        Schema schema = createAvroSchema();
+        initTable(tablePath, tableName);
+
+        // Commit 1 runs with the MDT off so the MDT bootstraps AFTER data exists. Index
+        // definitions get their source fields from ColumnStatsIndexer.postInitialization, which
+        // registers an EMPTY field list when the bootstrap sees no records, and
+        // HoodieJavaWriteClient.updateColumnsToIndexWithColStats is a no-op (the Spark client

Review Comment:
   The same no-op is tagged `HUDI-8801 to fix` in `JavaHoodieBackedTableMetadataWriter` and `HoodieFlinkWriteClient`. Citing that ticket here would let this fixture's MDT-off-first-commit workaround be dropped when it lands.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {

Review Comment:
   `catch (Exception expected)` also swallows the bare `IllegalArgumentException` that `getAllPartitionPaths` throws when the metadata table was never initialized, so this guard would pass if the fixture's MDT bootstrap ever stops happening - the case the new two-write-client split makes possible. Narrow it to `HoodieMetadataException`, which is what `BaseTableMetadata` wraps a genuine read failure in.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);

Review Comment:
   `corruptMetadataLogFiles` skips any log file below ~4.2KB and `checkState` only requires one file overall, so the small `partition_stats` deltas can survive untouched while the guard still passes on the `files` partition. Assert that a log file was corrupted in each MDT partition directory, not just one overall.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable

Review Comment:
   Done. `corruptMetadataLogFiles` is now followed by `verifyMetadataTableUnreadable`, which opens a `HoodieBackedTableMetadata` over the corrupted table and requires `getAllPartitionPaths()` (backed by the corrupted `files` partition) to throw -- initialization fails with an `IllegalStateException` otherwise, so the fallback tests can no longer pass vacuously if the trailer offsets ever miss.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.CORRUPTED_TABLE_NAME;
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ * <p>
+ * The initializer also writes {@code CORRUPTED_TABLE_NAME}, an identical table whose MDT log files
+ * are corrupted so every MDT read throws; queries on it pin the fallbacks (direct file listing,
+ * unpruned split generation) instead of only the clean-read path.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        MaterializedResult pruned = getQueryRunner().execute(partitionStatsPruningOnly(),
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        // Index pruning must scan exactly p1's file groups: the same split count as a
+        // metastore-pruned scan of p1, strictly fewer than the full scan. Split counts are
+        // compared instead of hardcoded because the number of file groups per partition depends
+        // on the write client's small-file packing.
+        int fullScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME);
+        int p1ScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME + " WHERE part_col = 'p1'");
+        assertThat(p1ScanSplits).isLessThan(fullScanSplits);
+        assertThat(pruned.getStatementStats().get().getTotalSplits()).isEqualTo(p1ScanSplits);
+    }
+
+    @Test
+    public void testReadFallsBackToDirectListingOnUnreadableMetadataTable()

Review Comment:
   Done. Refreshed the Tests paragraph: two tables (clean + corrupted twin with the read-must-fail assertion), the split-count assertions on both pruning tests, and the two fallback tests.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.CORRUPTED_TABLE_NAME;
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ * <p>
+ * The initializer also writes {@code CORRUPTED_TABLE_NAME}, an identical table whose MDT log files
+ * are corrupted so every MDT read throws; queries on it pin the fallbacks (direct file listing,
+ * unpruned split generation) instead of only the clean-read path.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        MaterializedResult pruned = getQueryRunner().execute(partitionStatsPruningOnly(),
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        // Index pruning must scan exactly p1's file groups: the same split count as a
+        // metastore-pruned scan of p1, strictly fewer than the full scan. Split counts are
+        // compared instead of hardcoded because the number of file groups per partition depends
+        // on the write client's small-file packing.
+        int fullScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME);
+        int p1ScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME + " WHERE part_col = 'p1'");
+        assertThat(p1ScanSplits).isLessThan(fullScanSplits);
+        assertThat(pruned.getStatementStats().get().getTotalSplits()).isEqualTo(p1ScanSplits);
+    }
+
+    @Test
+    public void testReadFallsBackToDirectListingOnUnreadableMetadataTable()
+    {
+        // The corrupted twin table's MDT log deltas cannot be decoded, so the MDT-backed
+        // file-system-view load throws; HudiSnapshotDirectoryLister must fall back to listing
+        // files directly from storage and still return complete, correct rows.
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + CORRUPTED_TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+    }
+
+    @Test
+    public void testPartitionStatsPruningFallsBackUnprunedOnUnreadableMetadataTable()
+    {
+        // Same pruning setup as above, but the partition_stats read throws on the corrupted
+        // table: prunePartitionsSafely must degrade to "no pruning", so the scan covers the
+        // same splits as a full scan instead of failing the query.
+        MaterializedResult unpruned = getQueryRunner().execute(partitionStatsPruningOnly(),
+                "SELECT id, price FROM " + CORRUPTED_TABLE_NAME + " WHERE price < 100");
+        assertThat(unpruned.getMaterializedRows()).hasSize(2);
+
+        int fullScanSplits = totalSplits(mdtDisabled(), "SELECT id, price FROM " + CORRUPTED_TABLE_NAME);
+        assertThat(unpruned.getStatementStats().get().getTotalSplits()).isEqualTo(fullScanSplits);
+    }
+
+    @Test
+    public void testColumnStatsFileSkippingOverUncompactedStats()

Review Comment:
   Done. The session now sets `withColumnStatsTimeout("10s")` (matching the col-stats tests in `TestHudiSmokeTest`), and the test asserts the filtered scan uses strictly fewer splits than the full scan, on top of the row check.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's

Review Comment:
   Missed that one, dropped. The class javadoc's format-based explanation is now the only story in the file.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

Posted by "wombatu-kun (via GitHub)" <gi...@apache.org>.
wombatu-kun commented on code in PR #19298:
URL: https://github.com/apache/hudi/pull/19298#discussion_r3691549767


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's

Review Comment:
   `createWriteClient`'s comment still says the zip fixtures use `compact.max.delta.commits=1`, which the class javadoc above it no longer claims - only 7 of the 16 fixture docs set it. Drop that parenthetical so the file carries one story about why the fixtures miss this.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {

Review Comment:
   The narrowed catch does not compile: `getAllPartitionPaths` declares `throws IOException`, and the try-with-resources resolves `close()` against `HoodieTableMetadata`, which inherits `throws Exception` from `AutoCloseable` - neither is covered by an unchecked `HoodieMetadataException` catch. Add a second `catch (Exception e)` arm that fails the fixture rather than returning, so the narrowing survives.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalarWith(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(false)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(true)
+                .build();
+        MaterializedResult pruned = getQueryRunner().execute(session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        MaterializedResult unpruned = getQueryRunner().execute(mdtEnabled(),
+                "SELECT id, price FROM " + TABLE_NAME);
+        // Pruning must not scan more than the full table does; correctness is asserted above
+        assertThat(pruned.getStatementStats().get().getTotalSplits())
+                .isLessThanOrEqualTo(unpruned.getStatementStats().get().getTotalSplits());
+    }
+
+    @Test
+    public void testColumnStatsFileSkippingOverUncompactedStats()
+    {
+        // Column-stats file skipping reads the column_stats MDT partition's HFILE log deltas
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(true)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(false)
+                .build();
+        assertQuery(
+                session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price = 15",
+                "VALUES ('k1', CAST(15 AS BIGINT))");
+    }
+
+    private Session mdtEnabled()
+    {
+        return SessionBuilder.from(getSession()).withMdtEnabled(true).build();
+    }
+
+    private Session mdtDisabled()
+    {
+        return SessionBuilder.from(getSession()).withMdtEnabled(false).build();

Review Comment:
   Done in 6506981.
   
   `AbstractTestQueryFramework` already has `computeScalar(Session, String)`, so the helper was redundant rather than misnamed. Dropped it and call the inherited one instead. Worth noting the literal suggestion would not compile: a `private computeScalar(Session, String)` cannot weaken the access of the inherited `protected` method.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,283 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert): k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert): k1(p1, price 15,  ts 300)
+ * </pre>
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.of(
+            new Column("_hoodie_commit_time", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_commit_seqno", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_record_key", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_partition_path", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_file_name", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("name", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("price", HIVE_LONG, Optional.empty(), Map.of()),
+            new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()));
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        Location tableLocation = externalLocation.appendPath(TABLE_NAME);
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            java.nio.file.Path tempTableDir = tempDir.resolve(TABLE_NAME);
+            writeTable(new Path(tempTableDir.toUri()));
+            ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+            metastore.createTable(createTableDefinition(schemaName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+            metastore.addPartitions(schemaName, TABLE_NAME, createPartitions(schemaName, tableLocation));
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    private static void writeTable(Path tablePath)
+    {
+        Schema schema = createAvroSchema();
+        try (HoodieJavaWriteClient<HoodieAvroPayload> writeClient = createWriteClient(schema, tablePath)) {
+            String firstCommit = writeClient.startCommit();
+            List<WriteStatus> firstStatuses = writeClient.insert(ImmutableList.of(
+                    record(schema, "k1", "k1_c1", 10L, 100L, PARTITION_PATHS.get(0)),
+                    record(schema, "k2", "k2_c1", 1000L, 100L, PARTITION_PATHS.get(1))), firstCommit);
+            writeClient.commit(firstCommit, firstStatuses);
+
+            String secondCommit = writeClient.startCommit();
+            List<WriteStatus> secondStatuses = writeClient.insert(ImmutableList.of(
+                    record(schema, "k3", "k3_c2", 20L, 200L, PARTITION_PATHS.get(0)),
+                    record(schema, "k4", "k4_c2", 2000L, 200L, PARTITION_PATHS.get(1))), secondCommit);
+            writeClient.commit(secondCommit, secondStatuses);
+
+            String thirdCommit = writeClient.startCommit();
+            List<WriteStatus> thirdStatuses = writeClient.upsert(ImmutableList.of(
+                    record(schema, "k1", "k1_c3", 15L, 300L, PARTITION_PATHS.get(0))), thirdCommit);
+            writeClient.commit(thirdCommit, thirdStatuses);
+        }
+    }
+
+    private static HoodieJavaWriteClient<HoodieAvroPayload> createWriteClient(Schema schema, Path tablePath)
+    {
+        Configuration conf = new Configuration();
+        try {
+            HoodieTableMetaClient.newTableBuilder()
+                    .setTableType(HoodieTableType.COPY_ON_WRITE)
+                    .setTableName(TABLE_NAME)
+                    .setTimelineLayoutVersion(1)
+                    .setBootstrapIndexClass(NoOpBootstrapIndex.class.getName())
+                    .setPayloadClassName(HoodieAvroPayload.class.getName())
+                    .setRecordKeyFields(RECORD_KEY_FIELD)
+                    .setPartitionFields(PARTITION_FIELD)
+                    .setHiveStylePartitioningEnable(true)
+                    .setOrderingFields(ORDERING_FIELD)
+                    .initTable(new HadoopStorageConfiguration(conf), tablePath.toString());
+        }
+        catch (IOException e) {
+            throw new RuntimeException("Could not init table " + TABLE_NAME, e);
+        }
+
+        HoodieWriteConfig cfg = HoodieWriteConfig.newBuilder()
+                .withPath(tablePath.toString())
+                .withSchema(schema.toString())
+                .withParallelism(2, 2)
+                .withDeleteParallelism(2)
+                .forTable(TABLE_NAME)
+                .withIndexConfig(HoodieIndexConfig.newBuilder().withIndexType(HoodieIndex.IndexType.INMEMORY).build())
+                .withCompactionConfig(HoodieCompactionConfig.newBuilder()
+                        .withInlineCompaction(false)
+                        .withMaxNumDeltaCommitsBeforeCompaction(100)
+                        .build())
+                .withEmbeddedTimelineServerEnabled(false)
+                .withMarkersType(MarkerType.DIRECT.name())
+                // The whole point of this initializer: an ENABLED metadata table with stats indexes,
+                // whose compaction never fires within this test (the zip fixtures use
+                // compact.max.delta.commits=1), so its partitions keep native HFILE log deltas.
+                // MDT HFILE writing is native (hudi-io HFileWriterImpl) -- no hbase involved.
+                .withMetadataConfig(HoodieMetadataConfig.newBuilder()
+                        .enable(true)
+                        .withMetadataIndexColumnStats(true)
+                        .withMetadataIndexPartitionStats(true)
+                        .withMaxNumDeltaCommitsBeforeCompaction(100)
+                        .build())
+                .build();
+        return new HoodieJavaWriteClient<>(new HoodieJavaEngineContext(new HadoopStorageConfiguration(conf)), cfg);

Review Comment:
   Leaving this one as is. `record(...)` is the existing convention for this helper across 12 other initializers in the same package (`CommitTimeOrderingHudiTablesInitializer`, `DmsPayloadHudiTablesInitializer`, `SummingPayloadHudiTablesInitializer`, `OmittedOrderingFieldHudiTablesInitializer`, and so on). Renaming only this file would make it the odd one out.
   
   Happy to do it as a package-wide sweep in a separate PR if a committer prefers `createRecord`.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalarWith(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(false)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(true)
+                .build();
+        MaterializedResult pruned = getQueryRunner().execute(session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        MaterializedResult unpruned = getQueryRunner().execute(mdtEnabled(),
+                "SELECT id, price FROM " + TABLE_NAME);
+        // Pruning must not scan more than the full table does; correctness is asserted above
+        assertThat(pruned.getStatementStats().get().getTotalSplits())
+                .isLessThanOrEqualTo(unpruned.getStatementStats().get().getTotalSplits());
+    }
+
+    @Test
+    public void testColumnStatsFileSkippingOverUncompactedStats()
+    {
+        // Column-stats file skipping reads the column_stats MDT partition's HFILE log deltas
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(true)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(false)
+                .build();
+        assertQuery(
+                session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price = 15",
+                "VALUES ('k1', CAST(15 AS BIGINT))");
+    }
+
+    private Session mdtEnabled()
+    {
+        return SessionBuilder.from(getSession()).withMdtEnabled(true).build();
+    }
+
+    private Session mdtDisabled()
+    {
+        return SessionBuilder.from(getSession()).withMdtEnabled(false).build();

Review Comment:
   🤖 nit: `computeScalarWith` is a little awkward — `with` is typically a builder prefix. Since `AbstractTestQueryFramework` already has `computeScalar(String)`, something like `computeScalar(Session, String)` would read more naturally and mirror the existing API shape.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,283 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert): k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert): k1(p1, price 15,  ts 300)
+ * </pre>
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.of(
+            new Column("_hoodie_commit_time", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_commit_seqno", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_record_key", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_partition_path", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("_hoodie_file_name", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("name", HIVE_STRING, Optional.empty(), Map.of()),
+            new Column("price", HIVE_LONG, Optional.empty(), Map.of()),
+            new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()));
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        Location tableLocation = externalLocation.appendPath(TABLE_NAME);
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            java.nio.file.Path tempTableDir = tempDir.resolve(TABLE_NAME);
+            writeTable(new Path(tempTableDir.toUri()));
+            ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+            metastore.createTable(createTableDefinition(schemaName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+            metastore.addPartitions(schemaName, TABLE_NAME, createPartitions(schemaName, tableLocation));
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    private static void writeTable(Path tablePath)
+    {
+        Schema schema = createAvroSchema();
+        try (HoodieJavaWriteClient<HoodieAvroPayload> writeClient = createWriteClient(schema, tablePath)) {
+            String firstCommit = writeClient.startCommit();
+            List<WriteStatus> firstStatuses = writeClient.insert(ImmutableList.of(
+                    record(schema, "k1", "k1_c1", 10L, 100L, PARTITION_PATHS.get(0)),
+                    record(schema, "k2", "k2_c1", 1000L, 100L, PARTITION_PATHS.get(1))), firstCommit);
+            writeClient.commit(firstCommit, firstStatuses);
+
+            String secondCommit = writeClient.startCommit();
+            List<WriteStatus> secondStatuses = writeClient.insert(ImmutableList.of(
+                    record(schema, "k3", "k3_c2", 20L, 200L, PARTITION_PATHS.get(0)),
+                    record(schema, "k4", "k4_c2", 2000L, 200L, PARTITION_PATHS.get(1))), secondCommit);
+            writeClient.commit(secondCommit, secondStatuses);
+
+            String thirdCommit = writeClient.startCommit();
+            List<WriteStatus> thirdStatuses = writeClient.upsert(ImmutableList.of(
+                    record(schema, "k1", "k1_c3", 15L, 300L, PARTITION_PATHS.get(0))), thirdCommit);
+            writeClient.commit(thirdCommit, thirdStatuses);
+        }
+    }
+
+    private static HoodieJavaWriteClient<HoodieAvroPayload> createWriteClient(Schema schema, Path tablePath)
+    {
+        Configuration conf = new Configuration();
+        try {
+            HoodieTableMetaClient.newTableBuilder()
+                    .setTableType(HoodieTableType.COPY_ON_WRITE)
+                    .setTableName(TABLE_NAME)
+                    .setTimelineLayoutVersion(1)
+                    .setBootstrapIndexClass(NoOpBootstrapIndex.class.getName())
+                    .setPayloadClassName(HoodieAvroPayload.class.getName())
+                    .setRecordKeyFields(RECORD_KEY_FIELD)
+                    .setPartitionFields(PARTITION_FIELD)
+                    .setHiveStylePartitioningEnable(true)
+                    .setOrderingFields(ORDERING_FIELD)
+                    .initTable(new HadoopStorageConfiguration(conf), tablePath.toString());
+        }
+        catch (IOException e) {
+            throw new RuntimeException("Could not init table " + TABLE_NAME, e);
+        }
+
+        HoodieWriteConfig cfg = HoodieWriteConfig.newBuilder()
+                .withPath(tablePath.toString())
+                .withSchema(schema.toString())
+                .withParallelism(2, 2)
+                .withDeleteParallelism(2)
+                .forTable(TABLE_NAME)
+                .withIndexConfig(HoodieIndexConfig.newBuilder().withIndexType(HoodieIndex.IndexType.INMEMORY).build())
+                .withCompactionConfig(HoodieCompactionConfig.newBuilder()
+                        .withInlineCompaction(false)
+                        .withMaxNumDeltaCommitsBeforeCompaction(100)
+                        .build())
+                .withEmbeddedTimelineServerEnabled(false)
+                .withMarkersType(MarkerType.DIRECT.name())
+                // The whole point of this initializer: an ENABLED metadata table with stats indexes,
+                // whose compaction never fires within this test (the zip fixtures use
+                // compact.max.delta.commits=1), so its partitions keep native HFILE log deltas.
+                // MDT HFILE writing is native (hudi-io HFileWriterImpl) -- no hbase involved.
+                .withMetadataConfig(HoodieMetadataConfig.newBuilder()
+                        .enable(true)
+                        .withMetadataIndexColumnStats(true)
+                        .withMetadataIndexPartitionStats(true)
+                        .withMaxNumDeltaCommitsBeforeCompaction(100)
+                        .build())
+                .build();
+        return new HoodieJavaWriteClient<>(new HoodieJavaEngineContext(new HadoopStorageConfiguration(conf)), cfg);

Review Comment:
   🤖 nit: `record()` reads as a noun (or a Java 16 record keyword), not a verb. Could you rename it to `buildRecord()` or `createRecord()` to make it clear at the call sites that this is a factory method?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

Posted by "wombatu-kun (via GitHub)" <gi...@apache.org>.
wombatu-kun commented on code in PR #19298:
URL: https://github.com/apache/hudi/pull/19298#discussion_r3690805803


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable

Review Comment:
   `checkState(corrupted > 0)` proves bytes were flipped, not that any MDT read now throws, so `testReadFallsBackToDirectListingOnUnreadableMetadataTable` cannot tell the fallback apart from a clean read if the fixed trailer offsets ever miss. Have the initializer assert that a metadata-table read of the corrupted table actually fails.
   



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable

Review Comment:
   Added. The initializer now writes a corrupted twin table (hudi_corrupted_mdt_pt_cow) whose MDT log files are damaged before copyDir, and two new tests pin the direct-listing fallback and the unpruned-pruning fallback on it. One subtlety: the damage targets the HFile trailer fields inside the block content, not the log block framing -- framing damage is classified as a HoodieCorruptBlock and skipped silently (records vanish, nothing throws), and bytes near EOF are only trailer padding. The helper has a comment on the offsets.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(false)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(true)
+                .build();
+        MaterializedResult pruned = getQueryRunner().execute(session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        MaterializedResult unpruned = getQueryRunner().execute(mdtEnabled(),
+                "SELECT id, price FROM " + TABLE_NAME);
+        // Pruning must not scan more than the full table does; correctness is asserted above
+        assertThat(pruned.getStatementStats().get().getTotalSplits())
+                .isLessThanOrEqualTo(unpruned.getStatementStats().get().getTotalSplits());

Review Comment:
   Tightened, though not to a literal: the pruned scan must now have exactly the split count of a metastore-pruned part_col = 'p1' scan, and strictly fewer than the full scan. Unlike the zip fixtures TestHudiSmokeTest asserts on, this table is written at test runtime, so file groups per partition depend on the write client's small-file packing; a hardcoded number would couple the test to that.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,283 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert): k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert): k1(p1, price 15,  ts 300)
+ * </pre>
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.of(
+            new Column("_hoodie_commit_time", HIVE_STRING, Optional.empty(), Map.of()),

Review Comment:
   Did it here since it was small: HUDI_META_COLUMNS in AbstractMergerHudiTablesInitializer is package-private now and the new initializer builds its DATA_COLUMNS on top of it. The Tpch and Resource initializers still carry identical private copies; left those for a separate sweep.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's

Review Comment:
   You are right, and it was neither compaction state nor entirely the swallowing paths. hudi_trips_cow_v8's 14KB files-partition delta is a #HUDI# block-format log carrying HFILE_DATA_BLOCKs (block type ordinal 4 in the header), which the connector already reads through its HFile content reader -- the smoke tests query that table MDT-on without issue. The unreadable kind is the whole-file native HFILE log (*.log.hfile, picked by filename in FSUtils.isNativeLogFile), which routes through HoodieNativeLogFileReader into the unimplemented getFileFormatUtils(HFILE) path; no zip fixture has those because they predate the native-log write path. Reworded the javadocs and the PR description, and corrected the corruption helper's comment, which described block framing these native files do not have.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);

Review Comment:
   Done. The helper now tracks partition directories and requires at least one corrupted log file in each one that has any, listing the untouched partitions in the failure message. The walk also skips anything not directly inside a partition directory, so timeline or marker leftovers cannot satisfy the check.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {

Review Comment:
   Done, narrowed to HoodieMetadataException with a comment on why the bare IllegalArgumentException from a never-initialized MDT must not pass.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {
+            return;
+        }
+        throw new IllegalStateException(
+                "Metadata table of " + CORRUPTED_TABLE_NAME + " is still readable (partitions: " + partitions
+                        + "); corruptMetadataLogFiles no longer lands on the HFile trailer fields");
+    }
+
+    private static void writeTable(Path tablePath, String tableName)
+    {
+        Schema schema = createAvroSchema();
+        initTable(tablePath, tableName);
+
+        // Commit 1 runs with the MDT off so the MDT bootstraps AFTER data exists. Index
+        // definitions get their source fields from ColumnStatsIndexer.postInitialization, which
+        // registers an EMPTY field list when the bootstrap sees no records, and
+        // HoodieJavaWriteClient.updateColumnsToIndexWithColStats is a no-op (the Spark client

Review Comment:
   Cited, and noted that the two-client split can collapse back to one when it lands.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(false)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(true)
+                .build();
+        MaterializedResult pruned = getQueryRunner().execute(session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        MaterializedResult unpruned = getQueryRunner().execute(mdtEnabled(),
+                "SELECT id, price FROM " + TABLE_NAME);
+        // Pruning must not scan more than the full table does; correctness is asserted above
+        assertThat(pruned.getStatementStats().get().getTotalSplits())
+                .isLessThanOrEqualTo(unpruned.getStatementStats().get().getTotalSplits());

Review Comment:
   Good call on the exact assertion -- it caught that pruning was not running at all. Tables written by HoodieJavaWriteClient bootstrap the MDT on an empty table, which registers the col-stats index definition with no source fields (and the Java client never refreshes it, unlike Spark), so canApply() rejected the index. The fixture now enables the MDT from commit 2 so the bootstrap sees data; the pruning tests assert real pruning now.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous merged PR #19298:
URL: https://github.com/apache/hudi/pull/19298


-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {

Review Comment:
   Fixed! [Hudi Trino Connector CI / test-hudi-trino-plugin (pull_request)](https://github.com/apache/hudi/actions/runs/30643408229/job/91199853559?pr=19298) is passing now.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert, MDT off): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert, MDT on):  k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert, MDT on):  k1(p1, price 15,  ts 300)
+ * </pre>
+ * The MDT is enabled only from commit 2 so its bootstrap sees existing data; a bootstrap over an
+ * empty table would register the col-stats index definition with no source fields, permanently
+ * disabling stats-based pruning in the connector (see {@code writeTable}).
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ * <p>
+ * A second, identical table {@link #CORRUPTED_TABLE_NAME} is written whose MDT log files are
+ * corrupted in place before upload: every MDT read of it throws, pinning the connector's
+ * fallbacks (direct file listing in {@code HudiSnapshotDirectoryLister}, unpruned split
+ * generation in {@code HudiBackgroundSplitLoader}) instead of only the clean-read path.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+    public static final String CORRUPTED_TABLE_NAME = "hudi_corrupted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.<Column>builder()
+            .addAll(AbstractMergerHudiTablesInitializer.HUDI_META_COLUMNS)
+            .add(new Column(RECORD_KEY_FIELD, HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("name", HIVE_STRING, Optional.empty(), Map.of()))
+            .add(new Column("price", HIVE_LONG, Optional.empty(), Map.of()))
+            .add(new Column(ORDERING_FIELD, HIVE_LONG, Optional.empty(), Map.of()))
+            .build();
+
+    private static final List<Column> PARTITION_COLUMNS =
+            ImmutableList.of(new Column(PARTITION_FIELD, HIVE_STRING, Optional.empty(), Map.of()));
+
+    @Override
+    public void initializeTables(QueryRunner queryRunner, Location externalLocation, String schemaName)
+            throws Exception
+    {
+        TrinoFileSystem fileSystem = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(TrinoFileSystemFactory.class)
+                .create(ConnectorIdentity.ofUser("test"));
+        HiveMetastore metastore = ((HudiConnector) queryRunner.getCoordinator().getConnector("hudi")).getInjector()
+                .getInstance(HiveMetastoreFactory.class)
+                .createMetastore(Optional.empty());
+
+        java.nio.file.Path tempDir = createTempDirectory("uncompacted-mdt");
+        try {
+            for (String tableName : ImmutableList.of(TABLE_NAME, CORRUPTED_TABLE_NAME)) {
+                java.nio.file.Path tempTableDir = tempDir.resolve(tableName);
+                writeTable(new Path(tempTableDir.toUri()), tableName);
+                if (tableName.equals(CORRUPTED_TABLE_NAME)) {
+                    corruptMetadataLogFiles(tempTableDir);
+                    verifyMetadataTableUnreadable(new Path(tempTableDir.toUri()));
+                }
+                Location tableLocation = externalLocation.appendPath(tableName);
+                ResourceHudiTablesInitializer.copyDir(tempTableDir, fileSystem, tableLocation);
+
+                metastore.createTable(createTableDefinition(schemaName, tableName, tableLocation), PrincipalPrivileges.NO_PRIVILEGES);
+                metastore.addPartitions(schemaName, tableName, createPartitions(schemaName, tableName, tableLocation));
+            }
+        }
+        finally {
+            deleteRecursively(tempDir, ALLOW_INSECURE);
+        }
+    }
+
+    /**
+     * Corrupts every MDT log file so that any metadata-table read of the table throws, without the
+     * log reader silently skipping the damage. The corrupted window targets the HFile TRAILER of
+     * the last block's content: hudi-io HFiles end with a fixed 4096-byte trailer whose magic and
+     * protobuf fields sit at the trailer's START, followed by padding, so the window is placed
+     * ~4KB before EOF to land on those fields (corrupting near EOF would only flip padding). The
+     * log block FRAMING -- the leading magic/block-size fields and the trailing footer plus
+     * reverse-pointer long, which {@code HoodieLogFileReader.isBlockCorrupted} validates -- stays
+     * intact on purpose: framing damage is classified as a {@code HoodieCorruptBlock} and skipped
+     * WITHOUT an exception, which would silently drop records instead of exercising the
+     * connector's fallbacks.
+     */
+    private static void corruptMetadataLogFiles(java.nio.file.Path tableDir)
+            throws IOException
+    {
+        java.nio.file.Path metadataDir = tableDir.resolve(".hoodie").resolve("metadata");
+        List<java.nio.file.Path> logFiles;
+        try (Stream<java.nio.file.Path> walk = Files.walk(metadataDir)) {
+            logFiles = walk
+                    .filter(Files::isRegularFile)
+                    .filter(file -> file.getFileName().toString().contains(".log."))
+                    .collect(toImmutableList());
+        }
+        int corrupted = 0;
+        for (java.nio.file.Path logFile : logFiles) {
+            byte[] bytes = Files.readAllBytes(logFile);
+            // The last block's content ends (up to the small log block footer) at EOF and its
+            // HFile trailer spans the content's final 4096 bytes, so the trailer's magic and
+            // fields sit just past EOF - 4160; a data-bearing block always reaches that deep
+            int start = bytes.length - 4160;
+            int end = bytes.length - 3648;
+            if (start < 64) {
+                // Too small to hold a data-bearing block (e.g. only the file-group bootstrap
+                // block, which carries no records); nothing worth corrupting
+                continue;
+            }
+            for (int i = start; i < end; i++) {
+                bytes[i] ^= 0x5A;
+            }
+            Files.write(logFile, bytes);
+            corrupted++;
+        }
+        checkState(corrupted > 0, "No MDT log files corrupted under %s; the fallback tests would pass vacuously", metadataDir);
+    }
+
+    /**
+     * Proves the corruption is effective, not just that bytes were flipped: a metadata-table read
+     * of the corrupted table must throw. This guards the fallback tests against the fixed trailer
+     * offsets in {@link #corruptMetadataLogFiles} ever missing (e.g. after an HFile layout change),
+     * in which case those tests would pass vacuously against a clean MDT read.
+     */
+    private static void verifyMetadataTableUnreadable(Path tablePath)
+    {
+        HadoopStorageConfiguration storageConf = new HadoopStorageConfiguration(new Configuration());
+        List<String> partitions;
+        try (HoodieTableMetadata metadata = new HoodieBackedTableMetadata(
+                new HoodieJavaEngineContext(storageConf),
+                HoodieStorageUtils.getStorage(tablePath.toString(), storageConf),
+                HoodieMetadataConfig.newBuilder().enable(true).build(),
+                tablePath.toString())) {
+            // The files partition backs getAllPartitionPaths; its log delta is corrupted like all others
+            partitions = metadata.getAllPartitionPaths();
+        }
+        catch (Exception expected) {

Review Comment:
   Fixed!



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalarWith(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(false)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(true)
+                .build();
+        MaterializedResult pruned = getQueryRunner().execute(session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        MaterializedResult unpruned = getQueryRunner().execute(mdtEnabled(),
+                "SELECT id, price FROM " + TABLE_NAME);
+        // Pruning must not scan more than the full table does; correctness is asserted above
+        assertThat(pruned.getStatementStats().get().getTotalSplits())
+                .isLessThanOrEqualTo(unpruned.getStatementStats().get().getTotalSplits());
+    }
+
+    @Test
+    public void testColumnStatsFileSkippingOverUncompactedStats()
+    {
+        // Column-stats file skipping reads the column_stats MDT partition's HFILE log deltas
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(true)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(false)
+                .build();
+        assertQuery(
+                session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price = 15",
+                "VALUES ('k1', CAST(15 AS BIGINT))");
+    }
+
+    private Session mdtEnabled()
+    {
+        return SessionBuilder.from(getSession()).withMdtEnabled(true).build();
+    }
+
+    private Session mdtDisabled()
+    {
+        return SessionBuilder.from(getSession()).withMdtEnabled(false).build();

Review Comment:
   Done.
   
   `AbstractTestQueryFramework` already has `computeScalar(Session, String)`, so the helper was redundant rather than misnamed. Dropped it and call the inherited one instead. Worth noting the literal suggestion would not compile: a `private computeScalar(Session, String)` cannot weaken the access of the inherited `protected` method.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 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


Re: [PR] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

Posted by "wombatu-kun (via GitHub)" <gi...@apache.org>.
wombatu-kun commented on code in PR #19298:
URL: https://github.com/apache/hudi/pull/19298#discussion_r3690268822


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        Session session = SessionBuilder.from(getSession())
+                .withMdtEnabled(true)
+                .withColStatsIndexEnabled(false)
+                .withRecordLevelIndexEnabled(false)
+                .withSecondaryIndexEnabled(false)
+                .withPartitionStatsIndexEnabled(true)
+                .build();
+        MaterializedResult pruned = getQueryRunner().execute(session,
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        MaterializedResult unpruned = getQueryRunner().execute(mdtEnabled(),
+                "SELECT id, price FROM " + TABLE_NAME);
+        // Pruning must not scan more than the full table does; correctness is asserted above
+        assertThat(pruned.getStatementStats().get().getTotalSplits())
+                .isLessThanOrEqualTo(unpruned.getStatementStats().get().getTotalSplits());

Review Comment:
   `isLessThanOrEqualTo` holds even when nothing is pruned, so this does not show that p2 was skipped. Assert the exact split count, the way the partition-pruning checks in `TestHudiSmokeTest` do.



##########
hudi-trino/src/main/java/io/trino/plugin/hudi/query/HudiSnapshotDirectoryLister.java:
##########
@@ -67,6 +84,22 @@ public HudiSnapshotDirectoryLister(
                 IndexSupportFactory.createIndexSupport(tableHandle, lazyMetaClient, lazyTableMetadata, tableHandle.getRegularPredicates(), session) : Optional.empty();
     }
 
+    /**
+     * Builds a file system view that lists files directly from storage, bypassing the metadata table.
+     * Used as the fallback when the metadata-table-backed view cannot be loaded (e.g. an MDT read
+     * failure); it lists lazily per partition, so no {@code loadAllPartitions()} here.
+     */
+    private static HoodieTableFileSystemView createDirectListingFileSystemView(HoodieTableMetaClient metaClient)

Review Comment:
   `HoodieTableFileSystemView.fileListingBasedFileSystemView` already builds a view over a `FileSystemBackedTableMetadata`, so the `HoodieMetadataConfig.enable(false)` plus `NativeTableMetadataFactory` detour is redundant here and its `reuse=true` argument is dead on that branch. Call it with the same completed-commits timeline `HudiUtil.getFileSystemView` uses.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ */
+public class TestHudiUncompactedMetadataTable

Review Comment:
   Both new guards - the catch in `prunePartitionsSafely` and the direct-listing fallback in `HudiSnapshotDirectoryLister` - have no test; every case here goes through the path where the MDT now reads cleanly. Could the initializer corrupt the MDT log files in the temp dir before `copyDir` so the fallbacks are pinned too?



##########
hudi-trino/src/main/java/io/trino/plugin/hudi/query/HudiSnapshotDirectoryLister.java:
##########
@@ -54,9 +58,22 @@ public HudiSnapshotDirectoryLister(
         this.lazyFileSystemView = Lazy.lazily(() -> {
             HoodieTimer timer = HoodieTimer.start();
             HoodieTableMetaClient metaClient = tableHandle.getMetaClient();
-            HoodieTableFileSystemView fileSystemView = getFileSystemView(lazyTableMetadata.get(), metaClient);
-            if (enableMetadataTable) {
-                fileSystemView.loadAllPartitions();
+            HoodieTableFileSystemView fileSystemView = null;
+            try {
+                fileSystemView = getFileSystemView(lazyTableMetadata.get(), metaClient);
+                if (enableMetadataTable) {
+                    fileSystemView.loadAllPartitions();
+                }
+            }
+            catch (Exception e) {
+                // A failure here is a metadata-table read failure (the metastore/table itself is
+                // fine), so fall back to direct file listing instead of failing the query.
+                if (fileSystemView != null && !fileSystemView.isClosed()) {
+                    fileSystemView.close();

Review Comment:
   `fileSystemView.close()` reaches `AbstractTableFileSystemView.closeResources`, which closes the `HoodieTableMetadata` the view was constructed with - here that is the shared `lazyTableMetadata` that `HudiBackgroundSplitLoader` and the index supports still read through the same `Lazy`, and `Lazy` never rebuilds it. Drop the close, since nothing else in the connector closes that instance today.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,283 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions with native HFILE LOG deltas
+ * that the connector must read at query time (issue apache/hudi#19279).
+ * <p>
+ * Note: MDT writing here is fully native -- HFILE base files and log blocks are written via hudi-io's
+ * pure-Java {@code HFileWriterImpl}, so no hbase dependency is involved (the "requires hbase" note in
+ * older initializers is stale).
+ * <p>
+ * Data layout (partitions {@code part_col=p1} / {@code part_col=p2}, hive-style paths so the MDT
+ * partition listing and the metastore agree on names):
+ * <pre>
+ * commit 1 (insert): k1(p1, price 10,  ts 100), k2(p2, price 1000, ts 100)
+ * commit 2 (insert): k3(p1, price 20,  ts 200), k4(p2, price 2000, ts 200)
+ * commit 3 (upsert): k1(p1, price 15,  ts 300)
+ * </pre>
+ * Final rows: k1=15, k2=1000, k3=20, k4=2000. Partition p1 holds prices [15, 20] and p2 holds
+ * [1000, 2000], so a predicate like {@code price < 100} lets the partition-stats index prune p2.
+ */
+public class UncompactedMetadataHudiTablesInitializer
+        implements HudiTablesInitializer
+{
+    public static final String TABLE_NAME = "hudi_uncompacted_mdt_pt_cow";
+
+    private static final String RECORD_KEY_FIELD = "id";
+    private static final String PARTITION_FIELD = "part_col";
+    private static final String ORDERING_FIELD = "ts";
+    private static final List<String> PARTITION_PATHS = ImmutableList.of(PARTITION_FIELD + "=p1", PARTITION_FIELD + "=p2");
+
+    private static final List<Column> DATA_COLUMNS = ImmutableList.of(
+            new Column("_hoodie_commit_time", HIVE_STRING, Optional.empty(), Map.of()),

Review Comment:
   These five `_hoodie_*` columns are already declared as `HUDI_META_COLUMNS` in `AbstractMergerHudiTablesInitializer`. Widen that constant's visibility and reuse it here - follow-up, not a blocker.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

Posted by "wombatu-kun (via GitHub)" <gi...@apache.org>.
wombatu-kun commented on code in PR #19298:
URL: https://github.com/apache/hudi/pull/19298#discussion_r3690802243


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.CORRUPTED_TABLE_NAME;
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ * <p>
+ * The initializer also writes {@code CORRUPTED_TABLE_NAME}, an identical table whose MDT log files
+ * are corrupted so every MDT read throws; queries on it pin the fallbacks (direct file listing,
+ * unpruned split generation) instead of only the clean-read path.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        MaterializedResult pruned = getQueryRunner().execute(partitionStatsPruningOnly(),
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        // Index pruning must scan exactly p1's file groups: the same split count as a
+        // metastore-pruned scan of p1, strictly fewer than the full scan. Split counts are
+        // compared instead of hardcoded because the number of file groups per partition depends
+        // on the write client's small-file packing.
+        int fullScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME);
+        int p1ScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME + " WHERE part_col = 'p1'");
+        assertThat(p1ScanSplits).isLessThan(fullScanSplits);
+        assertThat(pruned.getStatementStats().get().getTotalSplits()).isEqualTo(p1ScanSplits);
+    }
+
+    @Test
+    public void testReadFallsBackToDirectListingOnUnreadableMetadataTable()
+    {
+        // The corrupted twin table's MDT log deltas cannot be decoded, so the MDT-backed
+        // file-system-view load throws; HudiSnapshotDirectoryLister must fall back to listing
+        // files directly from storage and still return complete, correct rows.
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + CORRUPTED_TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+    }
+
+    @Test
+    public void testPartitionStatsPruningFallsBackUnprunedOnUnreadableMetadataTable()
+    {
+        // Same pruning setup as above, but the partition_stats read throws on the corrupted
+        // table: prunePartitionsSafely must degrade to "no pruning", so the scan covers the
+        // same splits as a full scan instead of failing the query.
+        MaterializedResult unpruned = getQueryRunner().execute(partitionStatsPruningOnly(),
+                "SELECT id, price FROM " + CORRUPTED_TABLE_NAME + " WHERE price < 100");
+        assertThat(unpruned.getMaterializedRows()).hasSize(2);
+
+        int fullScanSplits = totalSplits(mdtDisabled(), "SELECT id, price FROM " + CORRUPTED_TABLE_NAME);
+        assertThat(unpruned.getStatementStats().get().getTotalSplits()).isEqualTo(fullScanSplits);
+    }
+
+    @Test
+    public void testColumnStatsFileSkippingOverUncompactedStats()

Review Comment:
   This passes even when the col_stats deltas are never read: `shouldSkipFileSlice` returns false on any failure and once the default 1s `columnStatsWaitTimeout` elapses, which this session does not raise unlike every col-stats test in `TestHudiSmokeTest`. Assert pruned vs full split counts and set `withColumnStatsTimeout`.



##########
hudi-trino/src/test/java/io/trino/plugin/hudi/TestHudiUncompactedMetadataTable.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi;
+
+import io.trino.Session;
+import io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer;
+import io.trino.testing.AbstractTestQueryFramework;
+import io.trino.testing.MaterializedResult;
+import io.trino.testing.QueryRunner;
+import org.junit.jupiter.api.Test;
+
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.CORRUPTED_TABLE_NAME;
+import static io.trino.plugin.hudi.testing.UncompactedMetadataHudiTablesInitializer.TABLE_NAME;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression tests for apache/hudi#19279: queries on tables whose metadata table (MDT) has
+ * UNCOMPACTED delta commits. Those deltas are native HFILE log files, which the connector previously
+ * rejected ("Native HFILE log files are not supported..."), failing every query through the unguarded
+ * partition-stats pruning path. The table written by {@link UncompactedMetadataHudiTablesInitializer}
+ * keeps its MDT deliberately uncompacted (the zip fixtures always compact after every commit), so the
+ * queries below only succeed if the connector reads HFILE log deltas in the MDT's
+ * {@code files}/{@code column_stats}/{@code partition_stats} partitions.
+ * <p>
+ * The initializer also writes {@code CORRUPTED_TABLE_NAME}, an identical table whose MDT log files
+ * are corrupted so every MDT read throws; queries on it pin the fallbacks (direct file listing,
+ * unpruned split generation) instead of only the clean-read path.
+ */
+public class TestHudiUncompactedMetadataTable
+        extends AbstractTestQueryFramework
+{
+    @Override
+    protected QueryRunner createQueryRunner()
+            throws Exception
+    {
+        return HudiQueryRunner.builder()
+                .setDataLoader(new UncompactedMetadataHudiTablesInitializer())
+                .build();
+    }
+
+    @Test
+    public void testSnapshotReadWithUncompactedMetadataTable()
+    {
+        // MDT-backed file listing must read the files partition's HFILE log deltas
+        assertQuery(
+                mdtEnabled(),
+                "SELECT id, name, price FROM " + TABLE_NAME + " ORDER BY id",
+                "VALUES ('k1', 'k1_c3', CAST(15 AS BIGINT)), ('k2', 'k2_c1', 1000), ('k3', 'k3_c2', 20), ('k4', 'k4_c2', 2000)");
+        assertThat(computeScalar(mdtEnabled(), "SELECT count(*) FROM " + TABLE_NAME)).isEqualTo(4L);
+    }
+
+    @Test
+    public void testResultsMatchWithMetadataTableDisabled()
+    {
+        String query = "SELECT id, name, price, part_col FROM " + TABLE_NAME + " ORDER BY id";
+        MaterializedResult withMdt = getQueryRunner().execute(mdtEnabled(), query);
+        MaterializedResult withoutMdt = getQueryRunner().execute(mdtDisabled(), query);
+        assertThat(withMdt.getMaterializedRows()).isEqualTo(withoutMdt.getMaterializedRows());
+    }
+
+    @Test
+    public void testPartitionStatsIndexPruningOverUncompactedStats()
+    {
+        // The exact crash from the issue: partition-stats pruning reads the partition_stats MDT
+        // partition, whose deltas are uncompacted HFILE log files. Partition p2 holds prices
+        // [1000, 2000], so `price < 100` lets the index prune it entirely.
+        MaterializedResult pruned = getQueryRunner().execute(partitionStatsPruningOnly(),
+                "SELECT id, price FROM " + TABLE_NAME + " WHERE price < 100");
+        assertThat(pruned.getMaterializedRows()).hasSize(2);
+
+        // Index pruning must scan exactly p1's file groups: the same split count as a
+        // metastore-pruned scan of p1, strictly fewer than the full scan. Split counts are
+        // compared instead of hardcoded because the number of file groups per partition depends
+        // on the write client's small-file packing.
+        int fullScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME);
+        int p1ScanSplits = totalSplits(mdtEnabled(), "SELECT id, price FROM " + TABLE_NAME + " WHERE part_col = 'p1'");
+        assertThat(p1ScanSplits).isLessThan(fullScanSplits);
+        assertThat(pruned.getStatementStats().get().getTotalSplits()).isEqualTo(p1ScanSplits);
+    }
+
+    @Test
+    public void testReadFallsBackToDirectListingOnUnreadableMetadataTable()

Review Comment:
   The description's Tests paragraph still lists one table and four tests; the corrupted twin and these two fallback tests are not in it. Refresh it before merge.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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


##########
hudi-trino/src/test/java/io/trino/plugin/hudi/testing/UncompactedMetadataHudiTablesInitializer.java:
##########
@@ -0,0 +1,387 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.trino.plugin.hudi.testing;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import io.trino.filesystem.Location;
+import io.trino.filesystem.TrinoFileSystem;
+import io.trino.filesystem.TrinoFileSystemFactory;
+import io.trino.metastore.Column;
+import io.trino.metastore.HiveMetastore;
+import io.trino.metastore.HiveMetastoreFactory;
+import io.trino.metastore.Partition;
+import io.trino.metastore.PartitionStatistics;
+import io.trino.metastore.PartitionWithStatistics;
+import io.trino.metastore.PrincipalPrivileges;
+import io.trino.metastore.StorageFormat;
+import io.trino.metastore.Table;
+import io.trino.plugin.hudi.HudiConnector;
+import io.trino.spi.security.ConnectorIdentity;
+import io.trino.testing.QueryRunner;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.client.HoodieJavaWriteClient;
+import org.apache.hudi.client.WriteStatus;
+import org.apache.hudi.client.common.HoodieJavaEngineContext;
+import org.apache.hudi.common.bootstrap.index.NoOpBootstrapIndex;
+import org.apache.hudi.common.config.HoodieMetadataConfig;
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieAvroRecord;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.marker.MarkerType;
+import org.apache.hudi.common.util.HoodieStorageUtils;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.config.HoodieCompactionConfig;
+import org.apache.hudi.config.HoodieIndexConfig;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.index.HoodieIndex;
+import org.apache.hudi.metadata.HoodieBackedTableMetadata;
+import org.apache.hudi.metadata.HoodieTableMetadata;
+import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.io.MoreFiles.deleteRecursively;
+import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
+import static io.trino.hive.formats.HiveClassNames.HUDI_PARQUET_INPUT_FORMAT;
+import static io.trino.hive.formats.HiveClassNames.MAPRED_PARQUET_OUTPUT_FORMAT_CLASS;
+import static io.trino.hive.formats.HiveClassNames.PARQUET_HIVE_SERDE_CLASS;
+import static io.trino.metastore.HiveType.HIVE_LONG;
+import static io.trino.metastore.HiveType.HIVE_STRING;
+import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
+import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static java.nio.file.Files.createTempDirectory;
+
+/**
+ * Creates a partitioned COW table at test runtime with an ENABLED, UNCOMPACTED metadata table (MDT):
+ * {@code hoodie.metadata.compact.max.delta.commits} is set high (the zip fixtures use {@code =1}, so
+ * their MDTs are always freshly compacted) and several commits are written, leaving the MDT's

Review Comment:
   Missed that one -- dropped. The class javadoc's format-based explanation is now the only story in the file.



-- 
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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 545ca149fd1e9a5adcce8891c46f6ae702eaf51c Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494) 
   * 8ddb323e74f8e80c1f94524daa7b7aa89da0b557 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910) 
   * 65069818d05253f325105f0e79243cd631e9ba26 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915) 
   * 58c0aace26040d1c62a87dff52536deb675f19e5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920) 
   * 5ca644e8e18bb8161aa686d302aac25ff90d3114 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923) 
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * c045860085875239619e6c29c8db1de4889d3c27 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926) 
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * cd22194b900501176b7fe3ef3126f9ef90d32808 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928) 
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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] fix(trino): read uncompacted MDT HFILE log deltas and guard index pruning [hudi]

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15494",
       "triggerID" : "545ca149fd1e9a5adcce8891c46f6ae702eaf51c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15910",
       "triggerID" : "8ddb323e74f8e80c1f94524daa7b7aa89da0b557",
       "triggerType" : "PUSH"
     }, {
       "hash" : "65069818d05253f325105f0e79243cd631e9ba26",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15915",
       "triggerID" : "65069818d05253f325105f0e79243cd631e9ba26",
       "triggerType" : "PUSH"
     }, {
       "hash" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15920",
       "triggerID" : "58c0aace26040d1c62a87dff52536deb675f19e5",
       "triggerType" : "PUSH"
     }, {
       "hash" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15923",
       "triggerID" : "5ca644e8e18bb8161aa686d302aac25ff90d3114",
       "triggerType" : "PUSH"
     }, {
       "hash" : "c045860085875239619e6c29c8db1de4889d3c27",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15926",
       "triggerID" : "c045860085875239619e6c29c8db1de4889d3c27",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ea1b4dff039ae850aab9b406352f816965c0565c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15928",
       "triggerID" : "cd22194b900501176b7fe3ef3126f9ef90d32808",
       "triggerType" : "PUSH"
     }, {
       "hash" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932",
       "triggerID" : "701dfe74e56c2deeafb123987de1e7bbf5efa453",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * ea1b4dff039ae850aab9b406352f816965c0565c UNKNOWN
   * 701dfe74e56c2deeafb123987de1e7bbf5efa453 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15932) 
   
   <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