Skip to content

[Iceberg] Support async scan planning in Iceberg REST planning client - #7562

Open
Bartekszost wants to merge 7 commits into
delta-io:masterfrom
Bartekszost:irc-plan-get-support
Open

[Iceberg] Support async scan planning in Iceberg REST planning client#7562
Bartekszost wants to merge 7 commits into
delta-io:masterfrom
Bartekszost:irc-plan-get-support

Conversation

@Bartekszost

Copy link
Copy Markdown

Summary

  • Follow the Iceberg REST scan planning spec: when POST /plan returns submitted with a plan-id, poll GET /plan/{plan-id} (fetchPlanningResult) until the plan is terminal, matching Iceberg's RESTTableScan.
  • Poll with Iceberg's Tasks exponential backoff. Timeout, retries, min/max wait, and scale factor come from catalog /v1/config using the same rest-scan-planning.poll-* keys and defaults as Iceberg.
  • Completed responses still require inline file-scan-tasks. plan-tasks / fetchScanTasks pagination is out of scope.

Test plan

  • IcebergRESTCatalogPlanningClientSuite (Spark 4.1): poll until completed, retry exhaustion, missing fetch endpoint, terminal failed/cancelled, existing 503/404 and sync plan tests
  • CI on this PR

Follow the Iceberg REST scan planning spec: when POST /plan returns a
"submitted" status with a plan-id, poll GET /plan/{plan-id}
(fetchPlanningResult) until the plan reaches a terminal status, matching
the behavior of Iceberg's RESTTableScan.

- Switch on planStatus from POST /plan: completed converts inline file
  scan tasks as before; submitted requires a plan-id and polls; failed
  and cancelled surface the error payload.
- Poll with Iceberg's Tasks exponential backoff, retrying only while the
  plan is still submitted; poll timeout, retries, min/max wait, and
  scale factor are read from the catalog /v1/config properties, using
  the same rest-scan-planning.poll-* keys and defaults as Iceberg.
- Require the fetchPlanningResult endpoint to be advertised before
  polling, URL-encode the plan-id, and close the POST response before
  polling to avoid holding a pooled connection.
- Reject plan-tasks: completed responses must contain inline file scan
  tasks; plan-task pagination (fetchScanTasks) is not supported yet.
- Extend the test REST server and adapter to inject submitted responses
  and serve GET /plan/{plan-id}, and add tests covering poll-to-completed,
  retry exhaustion, missing endpoint, and terminal failed/cancelled.

Signed-off-by: Bartosz Szostakiewicz <b.szostakiewicz2003@gmail.com>
Copilot AI lite review requested due to automatic review settings August 31, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for Iceberg REST asynchronous scan planning in Delta’s Iceberg REST planning client: when POST .../plan returns SUBMITTED with a plan-id, the client polls GET .../plan/{plan-id} using Iceberg Tasks exponential backoff and poll settings derived from /v1/config.

Changes:

  • Implement polling of fetchPlanningResult for SUBMITTED scan plans, including terminal FAILED/CANCELLED handling and explicit rejection of plan-tasks pagination.
  • Expand /v1/config parsing to include endpoints and poll tuning properties (timeout/retries/min/max wait/scale factor).
  • Extend the shaded test REST server + servlet to simulate async planning and advertise (or omit) the fetch-planning-result endpoint; add corresponding suite coverage.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
iceberg/src/main/scala/org/apache/spark/sql/delta/serverSidePlanning/IcebergRESTCatalogPlanningClient.scala Adds async planning polling logic, poll configuration parsing, and endpoint capability checks.
iceberg/src/test/scala/org/apache/spark/sql/delta/serverSidePlanning/IcebergRESTCatalogPlanningClientSuite.scala Adds tests for async planning completion, retry exhaustion, missing endpoint, and terminal statuses.
iceberg/src/test/java/shadedForDelta/org/apache/iceberg/rest/IcebergRESTServletWithPlanSupport.java Enhances /v1/config to return defaults + endpoints and supports GET plan-result requests.
iceberg/src/test/java/shadedForDelta/org/apache/iceberg/rest/IcebergRESTServer.java Adds test hooks for config defaults, endpoint advertising, poll counting, and async status injection.
iceberg/src/test/java/shadedForDelta/org/apache/iceberg/rest/IcebergRESTCatalogAdapterWithPlanSupport.java Implements async planning simulation (submitted polls, terminal result responses) and poll request counting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 60 to +63
private case class CatalogConfigResponse(
defaults: Map[String, String],
overrides: Map[String, String])
overrides: Map[String, String],
endpoints: Option[Seq[String]] = None)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. defaults and overrides now default to empty maps, and the merge treats a null field as empty so a partial /v1/config body cannot NPE.

Default /v1/config defaults and overrides to empty maps so a partial
JSON body cannot NPE when merging catalog properties for poll settings.

Signed-off-by: Bartosz Szostakiewicz <b.szostakiewicz2003@gmail.com>
…d unsafe retries.

Reject delete files, cancel timed-out submitted plans, require an advertised fetch endpoint, and stop retrying POSTs that may already have allocated a plan-id.

Signed-off-by: Bartosz Szostakiewicz <b.szostakiewicz2003@gmail.com>
@Bartekszost
Bartekszost requested a review from murali-db August 31, 2026 20:40
Best-effort cancel submitted plans on any non-terminal poll exit, request vended credentials, close the planning client on failure, and stop retrying POST /plan on 5xx.

Signed-off-by: Bartosz Szostakiewicz <b.szostakiewicz2003@gmail.com>
Validate poll settings before POST /plan, cancel if fetchPlanningResult fails during setup, and memoize failed scanPlan so a later access does not reuse a closed client.

Signed-off-by: Bartosz Szostakiewicz <b.szostakiewicz2003@gmail.com>
@foss-contributor foss-contributor added delta-spark Issues and PRs related to general Delta-Spark issues delta-uniform 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-spark Issues and PRs related to general Delta-Spark issues delta-uniform enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants