You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "NikitaMatskevich (via GitHub)" <gi...@apache.org> on 2025/11/04 11:24:43 UTC

[I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

NikitaMatskevich opened a new issue, #2698:
URL: https://github.com/apache/iceberg-python/issues/2698

   ### Apache Iceberg version
   
   0.10.0 (latest release)
   
   ### Please describe the bug 🐞
   
   Starting from version 20, Pyarrow has support for Azure filesystems.
   
   ABFS URIs have this [format](https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri): abfs[s]://<file_system>@<account_name>.dfs.core.windows.net/<path>/<file_name>
   
   But Pyarrow library expects the following path format for Azure: abfs[s]://<file_system>/<path>/<file_name>.
   
   As you see, the part "@<account_name>.<dfs|blob>.core.windows.net" prevents users to use pyarrow file io in Azure environment. This issue CAN be fixed in Pyiceberg by removing account_name part.
   
   The proposed [fix](https://github.com/apache/iceberg-python/pull/2683) is just to start a conversation around the issue. I am not 100% sure how and where this should be fixed.
   
   We know similar issues do not occur with Fsspec file io.
   
   ### Willingness to contribute
   
   - [x] I can contribute a fix for this bug independently
   - [ ] I would be willing to contribute a fix for this bug with guidance from the Iceberg community
   - [ ] I cannot contribute a fix for this bug at this time


-- 
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: issues-unsubscribe@iceberg.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko closed issue #2698: PyArrowFile class is not compatible with ABFS uri syntax
URL: https://github.com/apache/iceberg-python/issues/2698


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-3488028973

   Thanks for opening the issue. 
   
   I wonder if this is an upstream issue. The correct syntax for abfs(s) is 
   ```
   abfs[s]://<file_system>@<account_name>.dfs.core.windows.net/<path>/<file_name>
   ```
   according to the [docs](https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri)
   
   Would be good to check what the expected path is for the pyarrow implementation


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "NikitaMatskevich (via GitHub)" <gi...@apache.org>.
NikitaMatskevich commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-3492056870

   Pyarrow library expects the following path format for Azure: abfs[s]://<file_system>//<file_name>.


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "krishnakaanchan-png (via GitHub)" <gi...@apache.org>.
krishnakaanchan-png commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-5482991757

   I looked into this and I think the diagnosis in the issue is slightly off, in a way that matters for where the fix goes.
   
   The issue says PyArrow expects `abfs://<file_system>/<path>`. That is not the case. PyArrow parses the canonical Azure URI correctly and pulls the account name out of it:
   
   ```python
   >>> from pyarrow.fs import FileSystem
   >>> FileSystem.from_uri("abfss://myfs@myacct.dfs.core.windows.net/wh/db/t/d.parquet")
   (<pyarrow._azurefs.AzureFileSystem object at 0x...>, 'myfs/wh/db/t/d.parquet')
   ```
   
   So the problem is entirely on our side. It is this line in `parse_location`, `pyiceberg/io/pyarrow.py:425`:
   
   ```python
   return uri.scheme, uri.netloc, f"{uri.netloc}{uri.path}"
   ```
   
   That rule is written for S3, where netloc is the bucket, so `bucket/key` is exactly what `S3FileSystem` wants. For Azure the netloc is `container@account.dfs.core.windows.net` and the whole thing gets pasted in front of the path:
   
   ```
   abfss://myfs@myacct.dfs.core.windows.net/wh/db/t/d.parquet
     -> ('abfss', 'myfs@myacct.dfs.core.windows.net',
         'myfs@myacct.dfs.core.windows.net/wh/db/t/d.parquet')
   ```
   
   PyArrow then takes the first path segment as the container. You can see the difference on the same filesystem object:
   
   ```python
   fs = AzureFileSystem(account_name="myacct")
   
   fs.get_file_info("myfs/wh/db/t/d.parquet")
   # Check for Hierarchical Namespace support on 'https://myacct.blob.core.windows.net/myfs' failed
   
   fs.get_file_info("myfs@myacct.dfs.core.windows.net/wh/db/t/d.parquet")
   # ListBlobsByHierarchy failed for prefix='wh/db/t/d.parquet'
   ```
   
   Both fail here only because I had no credentials, but the container we are asking for is different. In the second case we are asking for a container literally named `myfs@myacct.dfs.core.windows.net`. Per the [container naming rules](https://learn.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names) a container name has to be a valid DNS name, lowercase letters and numbers and hyphens only, 3 to 63 characters. `@` and `.` are not allowed. The same doc says a name that violates the rules fails with 400. So with working credentials this does not surface as a not found, it surfaces as a Bad Request, which makes it harder to recognise.
   
   The URI form itself is confirmed in [the ABFS URI doc](https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri), `abfs[s]://<file_system>@<account_name>.dfs.core.windows.net/<path>/<file_name>`, where file system is the same thing as a blob container.
   
   There is a second half to this. `_initialize_fs` calls `self._initialize_azure_fs()` with no arguments, unlike `_initialize_s3_fs(netloc)` and `_initialize_hdfs_fs(scheme, netloc)` right next to it. So the account name can only come from `adls.account-name` and the account in the location is dropped. That is why a location without the property set fails with `ArrowInvalid: AzureOptions doesn't contain a valid account name`, and it is also why a single FileIO cannot serve two accounts.
   
   `FsspecFileIO` already solves both of these. `_ADLS_SCHEMES` at `fsspec.py:334`, `uri.hostname` passed through for those schemes at `fsspec.py:498`, and the account derived as `hostname.split(".")[0]` at `fsspec.py:276` when the property is not set. So this can be framed as making `PyArrowFileIO` consistent with `FsspecFileIO` rather than as new behaviour.
   
   On why CI did not catch it. All the ADLS tests build their location as `f"{adls_scheme}://warehouse/{filename}"`, container only with no account, and the account is supplied to Azurite through properties. So we only ever exercise the one URI shape that happens to work. `test_parse_location` has hdfs and local cases and no Azure case at all.
   
   What I would like to do:
   
   1. An Azure branch in `parse_location` for `abfs`, `abfss`, `wasb`, `wasbs`, returning `f"{uri.username}{uri.path}"` when there is a userinfo part and falling back to current behaviour when there is not. Gating on `uri.username` and not on `uri.hostname` is deliberate, on the container only form `uri.hostname` is the container and inferring an account from it would break the existing tests.
   2. Pass netloc into `_initialize_azure_fs` and derive `account_name` from the hostname when `adls.account-name` is absent, same precedence as fsspec.
   3. Azure cases in `test_parse_location`, which need no infra, plus running the ADLS integration tests over the account qualified form as well.
   
   Three things I would rather have your call on before I write it:
   
   - Precedence when the property and the location disagree on the account. fsspec lets the property win. I am inclined to keep that for consistency, but property wins does mean a catalog spanning two accounts silently reads from the wrong one, so raising is also defensible. Which do you prefer?
   - Deriving the account as `hostname.split(".")[0]` holds for standard endpoints, private endpoints, sovereign clouds and the DNS zone endpoints, since the account is the first label in all of those. It does not hold if someone has mapped a [custom domain](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-custom-domain-name) on the blob endpoint. fsspec has the same limitation today. Fine to accept that, or do you want the property to be mandatory in that case?
   - I am leaving the endpoint and TLS side out of this. The scheme carries meaning in Azure, wasb goes to the blob endpoint and abfs to the dfs endpoint, and the trailing s indicates TLS, but we collapse all four schemes onto one `AzureFileSystem` and only the `adls.blob-storage-*` and `adls.dfs-storage-*` properties control any of it. Nothing is broken there today and inferring it from the scheme would change behaviour for anyone using those properties, so I think it belongs in a separate issue. Let me know if you disagree.
   
   I will keep this to #2698 only. This does fix the `PyArrowFileIO` part of #2271, but that one is fsspec plus a server side error from Nessie, so I do not want to claim it closes that.
   
   Separately, while reading this I think there is an unrelated bug in `_adls`. It writes the inferred account back into the dict it is given, and the call site at `fsspec.py:515` passes `self.properties`. So the first ADLS location a `FsspecFileIO` touches pins `adls.account-name` for every later location. The `lru_cache` on `(scheme, hostname)` above it correctly builds a fresh filesystem for a second account, then `_adls` skips the inference because the key now exists and hands back a filesystem pointing at the first account. Happy to raise that as its own issue if it is not already known.
   
   Checked on main with pyarrow 25.0.1.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-3488032846

   tagging @kyleknap since we were working on fsspec/adlfs together 


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "NikitaMatskevich (via GitHub)" <gi...@apache.org>.
NikitaMatskevich commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-3637234305

   @kyleknap could you look at this issue please? It is blocking some of our clients from using pyiceberg


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-3488041177

   Side note, as you suggested, we can try to fix this for our integration. This is the 2nd (3rd?) time where I've seen a FileIO implementation wanting to modify the path uri directly. (HDFS #2291 was the other case I can think of)


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] PyArrowFile class is not compatible with ABFS uri syntax [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #2698:
URL: https://github.com/apache/iceberg-python/issues/2698#issuecomment-4654926653

   This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org