feat(catalog-rest): wire TableScan to REST scan planning - #3012
Open
daviddallakyan2005 wants to merge 6 commits into
Open
feat(catalog-rest): wire TableScan to REST scan planning#3012daviddallakyan2005 wants to merge 6 commits into
daviddallakyan2005 wants to merge 6 commits into
Conversation
Port plan / fetch-result / cancel / fetch-tasks onto RestCatalog with a WaitForPlan poller. Task decoding and TableScan routing stay follow-ups, so supports_remote_scan_planning remains false. Part of apache#1690.
A huge Retry-After used to panic Duration::from_secs. Ignore overflow, await cancel when the poller times out, and DELETE the plan if the wait future is dropped.
RFC 9110 allows both delta-seconds and IMF-fixdate. Ignoring the date form made wait_for_plan retry immediately against a server that asked us to wait. Tests also cover cancelled/failed/expired poll outcomes and the namespace 404 split.
Decode REST content-file JSON into FileScanTask and auto-route TableScan::plan_files through a ScanPlanner with local fallback.
…lanning default REST content-file JSON uses kebab-case string discriminators and hex key-metadata. Decode each ScanTasks payload against its own delete-files. Default ScanPlanningMode to Local so existing scans do not POST /plan. Auto remotes only for scan-planning-mode=server. Share the live catalog client when injecting the planner.
OpenAPI defaults the flag to false (current table schema). TableScan always binds the snapshot schema, so time travel would plan against the wrong schema without this flag.
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.
Which issue does this PR close?
Stacked on #3011 (slices 1 to 3: REST plan / fetch / wait client). This is slice 4: wire
TableScan::plan_filesand decode REST content-file JSON.What changes are included in this PR?
ScanPlannerandScanPlanningMode::{Auto, Local, Remote}live in the iceberg crate. TheCatalogtrait is unchanged. Default mode isLocal(GoScanPlanningLocal, JavaCLIENT) so existingtable.scan().plan_files()does notPOST /planjust because the server advertised endpoints.RestCatalogimplementsScanPlannerand injects the already initialized catalog (shared HTTP client) onto tables it loads.clone_uninitializedstays only onPlanAbandonGuard.REST
ContentFile.contentis decoded as OpenAPI strings (data,position-deletes,equality-deletes) and as Avro ordinals 0/1/2. Data files may omit content. Delete files require a valid delete content type.delete-file-referencesare 0-based into that response'sdelete-files. EachScanTaskspayload is decoded on its own, thenFileScanTasks are appended.key-metadataaccepts OpenAPI uppercase hex text (and JSON byte arrays without truncatingas u8).Auto remotes only when
supports_remote_scan_planning()is true and table LoadTable/config (or metadata)scan-planning-modeisserver(case-insensitive). Missing key is client. ExplicitclientplusRemoteisFeatureUnsupported. Capability probesupports_remote_scan_planningstays true when all four endpoints are advertised.Remote plan POST sets
use-snapshot-schema=truewhenever a snapshot id is sent, so time travel plans against the snapshot schema. OpenAPI defaults the flag to false (current table schema).Out of scope (as agreed on #1690): DataFusion (#2671), plan-scoped FileIO / vended credentials (#2651 / #2932). Filter JSON on the wire is omitted (no ExpressionParser yet). The scan's bound predicate is stamped onto each task.
Remote Auto/Remote materializes the full FileScanTask list (plan-task handles expanded sequentially) before the stream yields, unlike local concurrent manifest streaming, and does not send the scan filter so the server cannot prune files. The planner reuses the live catalog client; typed content-file decode does not clone a JSON DOM per file.
Are these changes tested?
Unit tests with mockito (no docker / iceberg-rest-fixture).
"content": "data"and"content": "position-deletes"decode; integer 0/1 still work. Hex"key-metadata": "00000000000000000000000000000000"becomes 16 zero bytes. A delete file missing content isDataInvalid. Plan-task pageh1withdelete-file-references: [0]and its owndelete-filesresolves to that page's file, not a decoy from the parent payload. Defaultplan_fileswith four endpoints advertised does notPOST /plan.scan-planning-mode=clientplus Auto does notPOST /plan.scan-planning-mode=serverplus Auto doesPOST /plan. Afterload_tableplus Auto with no plan endpoints,GET /v1/configis expected once. Remote plan POST matchesuse-snapshot-schema: trueand the table's current snapshot id.How to test
Local results on
6233b7c: iceberg lib 1555 passed; iceberg-catalog-rest lib 131 passed; clippy-D warningsclean; rustfmt--checkclean.cargo public-api -p iceberg-catalog-rest --all-features -ssupdatedpublic-api.txtfor typedRestContentFile.cargo build -p iceberg-datafusioncompiles (no DataFusion source changes).--all-targetsfor that crate hit disk full while linking its test binary.AI Disclosure
https://iceberg.apache.org/contribute/#guidelines-for-ai-assisted-contributions
This change was drafted with an AI coding assistant. I reviewed the Go
PlanFiles/ScanPlannerdesign, Javascan-planning-modeanduse-snapshot-schema, OpenAPIContentFile, the maintainer review on this PR, and the resulting Rust diff.