AWS, Azure, Core, GCP, Spark: Add support for delimiter-based prefix listing - #17790
Open
tom-s-powell wants to merge 7 commits into
Open
AWS, Azure, Core, GCP, Spark: Add support for delimiter-based prefix listing#17790tom-s-powell wants to merge 7 commits into
tom-s-powell wants to merge 7 commits into
Conversation
tom-s-powell
commented
Aug 24, 2026
| class ADLSLocation { | ||
| private static final Pattern URI_PATTERN = Pattern.compile("^(abfss?|wasbs?)://([^/?#]+)(.*)?$"); | ||
|
|
||
| private final String scheme; |
Contributor
Author
There was a problem hiding this comment.
Raised #17594 separately to address this specific change
tom-s-powell
marked this pull request as ready for review
August 24, 2026 12:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR extends
SupportsPrefixOperationswith delimited prefix listing. The newlistPrefix(prefix, delimiter)method returns files directly below a prefix and common sub-prefixes grouped by the delimiter. Results are returned lazily as pages so that implementations can retain the pagination behaviour of the underlying storage service.The
supportsPrefixListingWithDelimiter(prefix, delimiter)method lets aFileIOreport whether it supports a specific delimiter. The new operation has default implementations, so existingSupportsPrefixOperationsimplementations remain compatible.Delimited prefix listing is implemented for S3, GCS, Azure Data Lake Storage, and Hadoop
FileIO. Wrapper implementations, includingResolvingFileIOandEncryptingFileIO, delegate the capability to their underlyingFileIO.Motivation
When
prefix_listing=true,remove_orphan_filescurrently lists all files from the Spark driver on one thread. For tables with many files, this can create a driver bottleneck and increase driver memory use.The Hadoop listing path already limits driver-side recursive listing. It discovers directories to a configured depth and then distributes the remaining directory listings across Spark executors. This PR applies the same approach to prefix-based listing.
I've be happy to split the PRs if preferred but figured it would be useful to understand the full scope of change.
Spark behaviour
The new
prefix_listing_max_seed_depthargument controls how many levels of common sub-prefixes are discovered on the driver before listing is distributed to Spark executors.When
prefix_listing_max_seed_depth=0, which is the default, the table location is used as a single seed prefix. Listing therefore uses one Spark partition, but it runs on an executor instead of the driver.When the value is greater than zero, the driver uses delimited prefix listing to discover seed prefixes up to that depth. Spark then distributes those prefixes, subject to the configured listing parallelism, so that executors can list them concurrently. Files found during seed discovery are retained and combined with the executor-side results.
This reduces driver-side work and memory use. For tables with a suitable directory or object-key layout, it also allows listing to run in parallel.
Testing
Unit tests added for all
FileIOimplementations and SparkRemoveOrphanFilesProcedure(all versions).Alternatives considered
I considered introducing a
SupportsDirectoryListingOperationsinterface or some such that extendsSupportsPrefixOperationsand deals specifically with listing directories thatremove_orphan_filescares about. This avoided thesupportsPrefixListingWithDelimiterbut felt a bit more of an invasive change.