You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by br...@apache.org on 2024/11/19 17:00:18 UTC
(iceberg) branch 1.7.1rc0-cherry-picks updated: Fix ADLSLocation file parsing (#11395)
This is an automated email from the ASF dual-hosted git repository.
bryanck pushed a commit to branch 1.7.1rc0-cherry-picks
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/1.7.1rc0-cherry-picks by this push:
new 79572571c1 Fix ADLSLocation file parsing (#11395)
79572571c1 is described below
commit 79572571c1c29292bbf5e80396113a967c4e685f
Author: Marc Cenac <54...@users.noreply.github.com>
AuthorDate: Tue Nov 5 17:55:56 2024 -0600
Fix ADLSLocation file parsing (#11395)
* Azure: Fix ADLSLocation file parsing
* Azure: Remove invalid test cases from ADLSLocationTest
* Update Javadocs with reference to ADLS URI
---
.../apache/iceberg/azure/adlsv2/ADLSLocation.java | 10 +++++----
.../iceberg/azure/adlsv2/ADLSLocationTest.java | 24 ++++++----------------
2 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java b/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java
index 26a8dac81a..deba414849 100644
--- a/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java
+++ b/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSLocation.java
@@ -25,9 +25,10 @@ import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
/**
- * This class represents a fully qualified location in Azure expressed as a URI.
+ * This class represents a fully qualified location to a file or directory in Azure Data Lake
+ * Storage Gen2 storage.
*
- * <p>Locations follow the conventions used by Hadoop's Azure support, i.e.
+ * <p>Locations follow a URI like structure to identify resources
*
* <pre>{@code abfs[s]://[<container>@]<storageAccount>.dfs.core.windows.net/<path>}</pre>
*
@@ -45,8 +46,9 @@ import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
* For compatibility, locations using the wasb scheme are also accepted but will use the Azure Data
* Lake Storage Gen2 REST APIs instead of the Blob Storage REST APIs.
*
- * <p>See <a href="https://hadoop.apache.org/docs/stable/hadoop-azure/abfs.html">Hadoop Azure
- * Support</a>
+ * <p>See <a
+ * href="https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri#uri-syntax">Azure
+ * Data Lake Storage URI</a>
*/
class ADLSLocation {
private static final Pattern URI_PATTERN = Pattern.compile("^(abfss?|wasbs?)://([^/?#]+)(.*)?$");
diff --git a/azure/src/test/java/org/apache/iceberg/azure/adlsv2/ADLSLocationTest.java b/azure/src/test/java/org/apache/iceberg/azure/adlsv2/ADLSLocationTest.java
index e07fea7439..10b5e1877c 100644
--- a/azure/src/test/java/org/apache/iceberg/azure/adlsv2/ADLSLocationTest.java
+++ b/azure/src/test/java/org/apache/iceberg/azure/adlsv2/ADLSLocationTest.java
@@ -93,23 +93,11 @@ public class ADLSLocationTest {
assertThat(location.path()).isEqualTo("");
}
- @Test
- public void testQueryAndFragment() {
- String p1 = "abfs://container@account.dfs.core.windows.net/path/to/file?query=foo#123";
- ADLSLocation location = new ADLSLocation(p1);
-
- assertThat(location.storageAccount()).isEqualTo("account.dfs.core.windows.net");
- assertThat(location.container().get()).isEqualTo("container");
- assertThat(location.path()).isEqualTo("path/to/file");
- }
-
- @Test
- public void testQueryAndFragmentNoPath() {
- String p1 = "abfs://container@account.dfs.core.windows.net?query=foo#123";
- ADLSLocation location = new ADLSLocation(p1);
-
- assertThat(location.storageAccount()).isEqualTo("account.dfs.core.windows.net");
- assertThat(location.container().get()).isEqualTo("container");
- assertThat(location.path()).isEqualTo("");
+ @ParameterizedTest
+ @ValueSource(strings = {"file?.txt", "file%3F.txt"})
+ public void testQuestionMarkInFileName(String path) {
+ String fullPath = String.format("abfs://container@account.dfs.core.windows.net/%s", path);
+ ADLSLocation location = new ADLSLocation(fullPath);
+ assertThat(location.path()).contains(path);
}
}