Skip to content

PyArrow: Derive the ADLS account from the location when it is not configured - #3936

Open
krishnakaanchan-png wants to merge 2 commits into
apache:mainfrom
krishnakaanchan-png:abfs-account-from-location
Open

PyArrow: Derive the ADLS account from the location when it is not configured#3936
krishnakaanchan-png wants to merge 2 commits into
apache:mainfrom
krishnakaanchan-png:abfs-account-from-location

Conversation

@krishnakaanchan-png

Copy link
Copy Markdown

Closes #2698

Builds on #3884, that one needs to go in first. Only the second commit here is new.

Rationale for this change

This is the other half of #2698. #3884 stops the account leaking into the path. This one lets the account be read from the location at all.

_initialize_azure_fs took no netloc, unlike _initialize_s3_fs(netloc) and _initialize_hdfs_fs(scheme, netloc) next to it. So account_name could only come from adls.account-name, and the account in an abfss://<container>@<account>.dfs.core.windows.net/... location was dropped. This leads to two things. A location without the property set failed with ArrowInvalid: AzureOptions doesn't contain a valid account name, and one FileIO could not serve two storage accounts.

Now the netloc is passed through and the account comes from its host part when the property is not set.

On precedence, an explicit adls.account-name still wins over the account in the location. I asked about this on #2698 and did not get a reply, so I have kept it the same as FsspecFileIO. That is the conservative choice, existing single account setups behave exactly as before. If you would rather it raised on a mismatch, tell me and I will change it.

The fallback is gated on the userinfo part being present, not on the hostname. On the container only form abfss://warehouse/f.parquet the netloc is the container, so inferring an account from it would give warehouse and break the existing ADLS tests.

Taking the account as the first label of the host holds for standard endpoints, private endpoints, sovereign clouds and the DNS zone endpoints. It does not hold for a custom domain on the blob endpoint. FsspecFileIO has the same limitation, so I have not tried to solve it here.

Are these changes tested?

Yes. I have added 4 new tests. The account coming from the location across all four ADLS schemes, an explicit property winning over the location, a container only netloc giving no account, and one FileIO serving two accounts and getting a separate filesystem for each.

make lint is clean and make test passes.

Are there any user-facing changes?

Yes. abfs[s] and wasb[s] locations that carry the account now work under PyArrowFileIO without adls.account-name being set, where earlier they failed with AzureOptions doesn't contain a valid account name. A single FileIO can also serve more than one storage account now.

Nothing changes when adls.account-name is set, or for the container only form.

For Azure the netloc is <container>@<account>.<host>, so building the path as
netloc + path put the account inside the path and PyArrow then read the whole
first segment as the container name. Return only the container instead, which
matches what PyArrow's own from_uri produces for the same location.
…figured

_initialize_azure_fs took no netloc, unlike the S3 and HDFS initialisers next to
it, so the account could only come from adls.account-name and the account in an
abfss location was dropped. Pass the netloc through and fall back to the account
in its host part. An explicit adls.account-name still wins, same precedence as
FsspecFileIO. The fallback is gated on the userinfo part being present, since a
container only netloc carries no account.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PyArrowFile class is not compatible with ABFS uri syntax

1 participant