Skip to content

[Spark] Rebalance file listing across tasks in CONVERT TO DELTA schema inference - #7570

Open
cravani wants to merge 1 commit into
delta-io:masterfrom
cravani:convert-rebalance-file-listing
Open

[Spark] Rebalance file listing across tasks in CONVERT TO DELTA schema inference#7570
cravani wants to merge 1 commit into
delta-io:masterfrom
cravani:convert-rebalance-file-listing

Conversation

@cravani

@cravani cravani commented Aug 31, 2026

Copy link
Copy Markdown

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

CONVERT TO DELTA infers the table schema by reading the Parquet footer of every source file. On the ManualListingFileManifest path (used when the table cannot use catalog partitions, e.g. native Unity Catalog parquet tables),
DeltaFileOperations.recursiveListDirs distributes the listed files across tasks by top-level directory. When one partition directory holds most of the files (e.g. a dominant country=US partition), that directory's footer reads all run in a single skewed task while the rest of the cluster is idle, the dominant cost of converting a many-file table.

This PR rebalances the listed files across tasks by file count (a footer read is ~constant cost per file) with a round-robin repartition inserted between the recursive listing and the footer reads in ManualListingFileManifest.allFiles It is gated by a new internal conf spark.databricks.delta.convert.rebalanceFileListing (default true; set to false to restore the previous per-directory distribution).

Effect: the single-directory skew is eliminated and footer-read work scales with cluster parallelism.
The converted table's schema, AddFile actions, and the data are unchanged.

How was this patch tested?

New unit test ConvertToDeltaListingRebalanceSuite builds a skewed layout (one country=US directory with 45 of 60 files) and checks the per-partition file-count distribution of allFiles with the conf OFF vs ON:

  • OFF: One partition holds 45 files (the skew): [45, 15].
  • ON: Files spread evenly across 8 tasks: [8,8,8,8,7,7,7,7], max 8.

Does this PR introduce any user-facing changes?

Not by default, added new config as a fall back when spark.databricks.delta.convert.rebalanceFileListing is set to false.

…st (e.g. a native Unity Catalog parquet table, which cannot use catalog partitions) reads every source file's Parquet footer to infer the schema. recursiveListDirs parcels those files by top-level directory, so a single large partition directory becomes one straggler task that reads all of its footers alone while the other cores idle.

Rebalance the listed files across tasks by file count (footer reads are ~constant cost per file) before reading footers, gated by an internal conf spark.databricks.delta.convert.rebalanceFileListing (default true). This removes the single-directory straggler and lets cluster parallelism apply to the footer reads. It does not change the resulting table schema, AddFiles, or data.

Signed-off-by: cravani <chiran54321@gmail.com>
@cravani
cravani force-pushed the convert-rebalance-file-listing branch from ff0f21c to 8837f89 Compare August 31, 2026 22:56
@foss-contributor foss-contributor added delta-ddl delta-spark Issues and PRs related to general Delta-Spark issues enhancement New feature or request labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delta-ddl delta-spark Issues and PRs related to general Delta-Spark issues enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants