You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "mbutrovich (via GitHub)" <gi...@apache.org> on 2025/12/10 20:43:25 UTC

[PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

mbutrovich opened a new pull request, #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #2871.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Normalize s3 paths in the key retriever cache.
   
   ## How are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Added a test that fails on main `native_datafusion` Parquet reader. With this change, the test passes.


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

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

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion-comet/pull/2874?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `9 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 10.08%. Comparing base ([`f09f8af`](https://app.codecov.io/gh/apache/datafusion-comet/commit/f09f8af64c6599255e116a376f4f008f2fd63b43?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ece15fb`](https://app.codecov.io/gh/apache/datafusion-comet/commit/ece15fb86a5ba45cc44570d93cb3151423783831?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 750 commits behind head on main.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/datafusion-comet/pull/2874?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...rg/apache/comet/parquet/CometFileKeyUnwrapper.java](https://app.codecov.io/gh/apache/datafusion-comet/pull/2874?src=pr&el=tree&filepath=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fcomet%2Fparquet%2FCometFileKeyUnwrapper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jb21ldC9wYXJxdWV0L0NvbWV0RmlsZUtleVVud3JhcHBlci5qYXZh) | 0.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion-comet/pull/2874?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               main    #2874       +/-   ##
   =============================================
   - Coverage     56.12%   10.08%   -46.05%     
   + Complexity      976      234      -742     
   =============================================
     Files           119      167       +48     
     Lines         11743    15287     +3544     
     Branches       2251     2508      +257     
   =============================================
   - Hits           6591     1541     -5050     
   - Misses         4012    13570     +9558     
   + Partials       1140      176      -964     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/datafusion-comet/pull/2874?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <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.
   </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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

Posted by "mbutrovich (via GitHub)" <gi...@apache.org>.
mbutrovich commented on code in PR #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874#discussion_r2608655725


##########
spark/src/test/scala/org/apache/comet/parquet/ParquetReadFromS3Suite.scala:
##########
@@ -76,4 +91,32 @@ class ParquetReadFromS3Suite extends CometS3TestBase with AdaptiveSparkPlanHelpe
     assertCometScan(df)
     assert(df.first().getLong(0) == 499500)
   }
+
+  test("write and read encrypted parquet from S3") {

Review Comment:
   It did fail on main, FWIW.



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

Posted by "mbutrovich (via GitHub)" <gi...@apache.org>.
mbutrovich merged PR #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874#discussion_r2608635616


##########
common/src/main/java/org/apache/comet/parquet/CometFileKeyUnwrapper.java:
##########
@@ -101,13 +101,33 @@ public class CometFileKeyUnwrapper {
   // Cache the hadoopConf just to assert the assumption above.
   private Configuration conf = null;
 
+  /**
+   * Normalizes S3 URI schemes to a canonical form. S3 can be accessed via multiple schemes (s3://,
+   * s3a://, s3n://) that refer to the same logical filesystem. This method ensures consistent cache
+   * lookups regardless of which scheme is used.
+   *
+   * @param filePath The file path that may contain an S3 URI
+   * @return The file path with normalized S3 scheme (s3a://)
+   */
+  private String normalizeS3Scheme(final String filePath) {
+    // Normalize s3:// and s3n:// to s3a:// for consistent cache lookups
+    // This handles the case where ObjectStoreUrl uses s3:// but Spark uses s3a://
+    if (filePath.startsWith("s3://")) {
+      return "s3a://" + filePath.substring(5);
+    } else if (filePath.startsWith("s3n://")) {
+      return "s3a://" + filePath.substring(6);
+    }

Review Comment:
   nit: rather than hard-code the lengths, I wonder if this would be clearer:
   
   ```suggestion
       String s3Prefix = "s3://";
       String s3nPrefix = "s3n://";
       if (filePath.startsWith(s3Prefix)) {
         return "s3a://" + filePath.substring(s3Prefix.length());
       } else if (filePath.startsWith(s3nPrefix)) {
         return "s3a://" + filePath.substring(s3nPrefix.length());
       }
   ```



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874#discussion_r2608635616


##########
common/src/main/java/org/apache/comet/parquet/CometFileKeyUnwrapper.java:
##########
@@ -101,13 +101,33 @@ public class CometFileKeyUnwrapper {
   // Cache the hadoopConf just to assert the assumption above.
   private Configuration conf = null;
 
+  /**
+   * Normalizes S3 URI schemes to a canonical form. S3 can be accessed via multiple schemes (s3://,
+   * s3a://, s3n://) that refer to the same logical filesystem. This method ensures consistent cache
+   * lookups regardless of which scheme is used.
+   *
+   * @param filePath The file path that may contain an S3 URI
+   * @return The file path with normalized S3 scheme (s3a://)
+   */
+  private String normalizeS3Scheme(final String filePath) {
+    // Normalize s3:// and s3n:// to s3a:// for consistent cache lookups
+    // This handles the case where ObjectStoreUrl uses s3:// but Spark uses s3a://
+    if (filePath.startsWith("s3://")) {
+      return "s3a://" + filePath.substring(5);
+    } else if (filePath.startsWith("s3n://")) {
+      return "s3a://" + filePath.substring(6);
+    }

Review Comment:
   nit: rather than hard-code the lengths, I wonder if this would be clearer:
   
   ```suggestion
       if (filePath.startsWith("s3://")) {
         return "s3a://" + filePath.substring(5);
       } else if (filePath.startsWith("s3n://")) {
         return "s3a://" + filePath.substring(6);
       }
   ```



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874#discussion_r2608640930


##########
spark/src/test/scala/org/apache/comet/parquet/ParquetReadFromS3Suite.scala:
##########
@@ -76,4 +91,32 @@ class ParquetReadFromS3Suite extends CometS3TestBase with AdaptiveSparkPlanHelpe
     assertCometScan(df)
     assert(df.first().getLong(0) == 499500)
   }
+
+  test("write and read encrypted parquet from S3") {

Review Comment:
   I don't know if this test excercises the changes to normalizing the path or not, but the test looks good



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Normalize s3 paths for PME key retriever [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #2874:
URL: https://github.com/apache/datafusion-comet/pull/2874#discussion_r2608640930


##########
spark/src/test/scala/org/apache/comet/parquet/ParquetReadFromS3Suite.scala:
##########
@@ -76,4 +91,32 @@ class ParquetReadFromS3Suite extends CometS3TestBase with AdaptiveSparkPlanHelpe
     assertCometScan(df)
     assert(df.first().getLong(0) == 499500)
   }
+
+  test("write and read encrypted parquet from S3") {

Review Comment:
   I don't know if this test exercises the changes to normalizing the path or not, but the test looks good



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org