Skip to content

Conversation

@geruh
Copy link
Contributor

@geruh geruh commented Nov 22, 2025

Summary

This PR fixes scan planning behavior for empty tables in both sync and async modes. While testing the rest fixture, I found that scanning empty tables throws NoSuchPlanIdException. This changes the behavior to return an empty plan instead.

Error:

{
  "error": {
    "message": "Could not find plan ID ccccab5e-9195-422d-b9c0-86b6b6feecad",
    "type": "NoSuchPlanIdException",
    "code": 404,
    "stack": [
      "org.apache.iceberg.exceptions.NoSuchPlanIdException: Could not find plan ID ccccab5e-9195-422d-b9c0-86b6b6feecad",
      "\tat org.apache.iceberg.rest.InMemoryPlanningState.initialScanTasksFor(InMemoryPlanningState.java:116)",
      "\tat org.apache.iceberg.rest.CatalogHandlers.planTableScan(CatalogHandlers.java:675)",
      "\tat org.apache.iceberg.rest.RESTCatalogAdapter.handleRequest(RESTCatalogAdapter.java:311)",
      ....
    ]
  }
}

Testing

Testing with the Docker fixture:

  ./gradlew :iceberg-open-api:shadowJar
  
  docker build -t apache/iceberg-rest-fixture -f docker/iceberg-rest-fixture/Dockerfile .
  
  docker run -d -p 8181:8181 ....

  curl -X POST http://localhost:8181/v1/namespaces/test/tables/empty-tbl/plan \
    -H "Content-Type: application/json" \
    -d '{}'

Returns an empty scan with the fix!

{
  "status": "completed",
  "plan-id": "sync-a1d448e2-c976-4bca-9a02-92a106e535ae",
  "file-scan-tasks": []
}

Note: There aren't any tests for scan planning yet, but those are being added in the client side pr.

cc: @singhpk234 @amogh-jahagirdar @kevinjqliu

@github-actions github-actions bot added the core label Nov 22, 2025
@singhpk234 singhpk234 changed the title Core: fix NoSuchPlanIdException when scanning empty tables with server-side planning Core: Handle empty tables in RESTCatalogAdapter for server side planning Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants