[#11284] feat(iceberg-rest): Add the fetch scan tasks endpoint and its plumbing - #12412
Open
laserninja wants to merge 1 commit into
Open
[#11284] feat(iceberg-rest): Add the fetch scan tasks endpoint and its plumbing#12412laserninja wants to merge 1 commit into
laserninja wants to merge 1 commit into
Conversation
…and its plumbing
Wire `POST /v1/{prefix}/namespaces/{namespace}/tables/{table}/tasks`, the
second step of the Iceberg REST two-step scan planning protocol, through the
Iceberg REST server: the JAX-RS resource, the table dispatcher chain, the
`FETCH_SCAN_TASKS` audit operation with its three listener events, and
`NoSuchPlanTaskException` mapped to 404.
Scan planning still returns every file scan task inline and hands out no
`plan-tasks`, so no plan task presented to this endpoint was issued by this
server and every request is rejected as unknown. The endpoint is deliberately
not advertised in `/v1/config` while that is the case, so a spec-compliant
client never reaches it. Batching a plan into plan tasks, and redeeming them
here, follows in a later change.
Also report a 400 rather than a 500 when either scan planning endpoint is
called without a request body: Jersey passes a null entity, which would
otherwise surface as a downstream NPE.
This was referenced Aug 10, 2026
Code Coverage Report
Files
|
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.
What changes were proposed in this pull request?
This is PR 2 of the stack that splits #12194, as agreed with @nevzheng (plan). PR 1 is #12411.
It wires up
POST /v1/{prefix}/namespaces/{namespace}/tables/{table}/tasks, the second step of the Iceberg REST two-step scan planning protocol, without yet implementing what it hands back:IcebergTableOperations.fetchScanTasks- the JAX-RS resource, with the same authorization expression asPOST .../plansince it is the same read of the same table.fetchScanTasksthrough the table dispatcher chain:IcebergTableOperationDispatcher(interface),IcebergTableEventDispatcher(events),IcebergTableHookDispatcher(pass-through, the operation is read-only),IcebergTableOperationExecutor(delegation to the catalog wrapper).OperationType.FETCH_SCAN_TASKSandAuditLog.Operation.FETCH_SCAN_TASKS, withIcebergFetchScanTasksPreEvent,IcebergFetchScanTasksEventandIcebergFetchScanTasksFailureEvent.NoSuchPlanTaskExceptionmapped to404inIcebergExceptionMapper.CatalogWrapperForREST.planTableScanstill returns every file scan task inline and hands out noplan-tasks, so no plan task presented to this endpoint was issued by this server, andCatalogWrapperForREST.fetchScanTasksrejects every one of them as unknown. Two deliberate consequences:/v1/config. Clients gate on the advertised endpoint set rather than probing - pyiceberg enables server-side scan planning when it seesPOST .../tasksthere, and fails the scan if the endpoint then serves nothing. Advertising it before it can return tasks would be worse than not having it. From a client's point of view this PR leaves behaviour exactly as it is today.TestIcebergFetchScanTasksEndpointwhich exercises it end to end. I checked thatFetchScanTasksResponseis already covered byRESTSerializers.registerAll, so the response serialization this PR leaves untested is not an open question.One change here is not strictly about
/tasks: both scan planning endpoints now report400instead of500when called with no request body. Jersey passes the resource method anullentity, which became an NPE downstream./tasksneeded the guard, and applying the same three lines to/planseemed better than leaving the neighbouring endpoint wrong. Happy to drop it into its own PR if you would rather keep this one single-purpose.Why are the changes needed?
#11284 asks for the fetch scan tasks endpoint. Reviewers on #12194 asked for that work in reviewable pieces; this is the plumbing piece, separated from the batching logic that gives it something to return.
Fix: #11284
Does this PR introduce any user-facing change?
A new REST route exists but is not advertised, and answers
404 NoSuchPlanTaskExceptionfor any plan task. No new configuration properties. The only behaviour change a user can observe is thatPOST .../planandPOST .../taskswith an empty body now return400instead of500.How was this patch tested?
./gradlew :iceberg:iceberg-rest-server:check -PskipITsand./gradlew :core:test --tests "*TestCompatibilityUtils*", both green.Three tests added to
TestIcebergTableOperations, each run against both a flat and a nested namespace:testFetchScanTasksUnknownPlanTask- a plan task this server never issued is a404. Asserts on the error payload (typeisNoSuchPlanTaskException, message names the rejected plan task), not just the status, so it cannot pass against an unregistered route. Asserts the pre event and the failure event are dispatched.testFetchScanTasksTableNotFound- a missing table reportsNoSuchTableException, not a masked unknown plan task.testScanPlanningEndpointsRejectMissingRequestBody- an empty body on/planand on/tasksis a400.