Hi Giuseppe,

Thanks for picking up as discussed on Slack :)

Overall it looks good to me.

A few comments our your points:

1. +1 on the module layout. Following the metrics-reports layout
(api/spi/base) matches what Dmitri suggested. One thing to decide
early: what runtime/service does when no planner implementation is on
the classpath. I would expect it to behave exactly like the flag being
off: 406 on the endpoints, and nothing in /v1/config.

2. +1 on Polaris owning the REST response, the plan-id and the
credentials. I have two suggestions:
- Let Polaris own the plan task envelope as well. The planner returns
its remaining work as an opaque payload. Polaris wraps it with the
table UUID, the snapshot id and a format version. On /tasks, Polaris
re-authorizes and checks the envelope before handing the payload back
to the planner. That keeps the check in one place, whether the planner
is local or a delegation service later. The version lets us change the
format later without breaking scans that are in flight during a
rolling upgrade.
- Be explicit about how the local planner reads manifests. I would
pass it a FileIO (or the loaded Table) prepared by Polaris, so that
"no Polaris credentials in the SPI" also holds on the input side.

3. +1 on TABLE_READ_DATA. It is consistent with
LOAD_TABLE_WITH_READ_DELEGATION and REPORT_READ_METRICS, and it is
needed even without credential vending, because the response exposes
column bounds. One operation per endpoint is enough: unlike loadTable,
there is no write delegation to fall back from. On naming, these names
become part of the OPA contract and also need entries in the Ranger
semantics, so I would reuse the Iceberg operationIds: PLAN_TABLE_SCAN
and FETCH_SCAN_TASKS now, and FETCH_PLANNING_RESULT and
CANCEL_PLANNING in phase 1b. Then nobody has to guess the mapping. I
would add the 1b operations only when they are implemented, together
with the ownership rules.

4. +1 about events. The same applies to the /tasks events: if the plan
task carries the filter, the plan task string is as sensitive as the
filter. I would also keep the AFTER_ events to identifiers and counts
rather than the response body, since the response contains vended
crendentials and column bounds.

5. +1 to have the flag off by default. I would make it a
FeatureConfiguration with a catalog-level override (like
ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING), so an operator can enable
it on one catalog first. That affects /v1/config:
CatalogConfigEndpointContributor.endpoints() has no catalog argument
today. Advertising the endpoints per catalog (and not for external and
federated catalogs, which return 406) therefore needs a small change
to that interface. Please call that out explicitly in the PR. And yes,
406 is the right code: the spec defines it for unsupported operations.

6. +1 on stateless plan tasks. FetchScanTasksRequest only carries the
plan task string, so the plan task has to carry the whole scan context
(snapshot id, filter, projection, case sensitivity, stats fields,
...), not just the manifest. It is client input, so I would treat it
as untrusted:
- Refer to the manifest by its position in the snapshot's manifest
list rather than by its path. Membership is then implicit, and the
server never opens a location supplied by the client.
- Bind the plan task to the table UUID, and reject it if it is sent to
another table's /tasks path.
With re-authorization plus these checks, a tampered plan task gives
the caller nothing they could not get from /plan directly. So I don't
think we need to sign plan tasks in 1a, which also avoids key
management. That changes in 1b, when plans get an owner.

One cost to to keep in mind: each /tasks response must include every
delete file referenced by its file scan tasks, so each call needs the
snapshot's delete index I think. On merge-on-read tables with many
delete manifests, that means re-reading the delete manifests on every
/tasks call. That's fine for 1a, and it's good first target for the
catching layer in phase 2.

On Prashant's plan-id concern, in 1a, a plan-id is just an identifier.
The spec requires it on a completed response, but it carries no state
and grants no access, so the leakage concern doesn't apply yet I
guess. loadCredentials already accepts a planId parameter and ignores
it. I would keep it that way until the 1b proposal defines plan
ownership.

Happy to review the PRs :)

Regards
JB

On Wed, Dec 2, 2026 at 3:18 PM Giuseppe Vulduraro
<[email protected]> wrote:
>
> Hi all,
>
> Thanks, Tornike and Yufei. I opened #6294
> <https://github.com/apache/polaris/issues/6294> to track phase 1. Before
> the first PRs, I'd like to agree on a few design points. My proposals:
>
> 1. Module layout: a scan planning SPI plus one implementation module under
> extensions/, like the metrics API (#4115
> <https://github.com/apache/polaris/pull/4115>), so downstream builds can
> leave planning out. The endpoint methods stay in runtime/service, since
> they come from the generated Iceberg API.
>
> 2. SPI shape: the planner returns file scan tasks and remaining work;
> Polaris builds the REST response, including plan-id, plan tasks and vended
> credentials. This keeps Polaris's own credentials out of the SPI, and a
> delegation service could implement it later.
>
> 3. Authorization: new operations (e.g. PLAN_TABLE_SCAN, FETCH_SCAN_TASKS)
> mapped to TABLE_READ_DATA, since the returned column stats expose data
> values. Their names become part of the OPA contract.
>
> 4. Events: new BEFORE_/AFTER_ event types for the new endpoints, without
> the filter expression, whose literals may be sensitive.
>
> 5. Flag: off by default, checked in the handler and in the /v1/config
> advertisement. External and federated catalogs reject /plan with 406.
>
> 6. Plan tasks: one per manifest of the scanned snapshot, resolved through
> the table's own metadata after re-authorizing, so any instance can serve
> /tasks without stored state.
>
> Do these look reasonable? I'd especially appreciate feedback on 2 and 3,
> since the SPI and the operation names are the hardest to change later.
> Meanwhile I'll start on the first PR (spec and generated clients), which
> doesn't depend on these choices.
>
> Thanks,
> Giuseppe
>
> Il giorno mar 1 dic 2026 alle ore 18:28 Yufei Gu <[email protected]> ha
> scritto:
>
> > Hi Giuseppe, +1 on the scan planning phase 1. Thanks for picking it up!
> > Yufei
> >
> >
> > On Tue, Dec 1, 2026 at 9:22 AM Tornike Gurgenidze <[email protected]>
> > wrote:
> >
> > > Hi Giuseppe,
> > >
> > > I haven't started on it, no. Feel free to take it up. ping me on gh, I
> > can
> > > help review as much as I can.
> > >
> > > Thanks,
> > > Tornike
> > >
> > > On Tue, Dec 1, 2026 at 5:52 PM Giuseppe <[email protected]>
> > > wrote:
> > >
> > > > Hi Tornike, all,
> > > >
> > > > Is phase 1 still on your plan? If you don't have time for it, I'd like
> > > > to implement phase 1a. If you're already working on it, I'm happy to
> > > > help on your branch instead.
> > > >
> > > > A few notes on phase 1a after re-reading the doc and the thread:
> > > >
> > > > - Iceberg 1.12, which Polaris already uses, ships server-side handlers
> > > > for all four operations (CatalogHandlers.planTableScan etc.). Their
> > plan
> > > > state is an in-memory map per JVM with no notion of the caller, so we
> > > > can reuse their planning logic but not their state.
> > > > - Prashant's one-plan-task-per-manifest idea fits well: if a plan task
> > > > just identifies a manifest of the scanned snapshot, any instance can
> > > > serve /tasks without stored state. The server only has to check that
> > the
> > > > manifest belongs to the table.
> > > > - Agreed that the planner interface should let a delegation service
> > > > return the same results later. I'd settle the details in the PRs.
> > > >
> > > > I'd split phase 1a into small PRs:
> > > >
> > > > 1. Spec, generated clients and a feature flag, off by default.
> > > > 2. The synchronous endpoint with the authorization operations from your
> > > > doc (RBAC, Ranger, OPA).
> > > > 3. /v1/config advertising it only when enabled, plus Spark regression
> > > > tests (scan-planning-mode=server).
> > > >
> > > > For phase 1b, building on Prashant's plan-id point, I could write a
> > > > short proposal for plan ownership: a plan is bound to the principal
> > that
> > > > created it, and any other caller gets the same response as for an
> > > > unknown plan-id.
> > > >
> > > > Let me know what you think.
> > > >
> > > > Thanks,
> > > > Giuseppe
> > > >
> > > > On 6/22/2026 9:00 PM, Prashant Singh wrote:
> > > > > Hi Tornike,
> > > > >
> > > > > Thanks for putting this proposal together. It makes sense to tackle
> > > this
> > > > > problem with an incremental approach, especially since it's an opt-in
> > > > > feature, default disabled.
> > > > >
> > > > > However, there are a few specific areas I’d like to discuss further
> > > > before
> > > > > we finalize the direction:
> > > > >
> > > > >     -
> > > > >
> > > > >     *Authorization and plan-id Leakage:* If the plan-id is included
> > in
> > > > the
> > > > >     query parameters, it will inevitably be logged. My concern is
> > > > whether User
> > > > >     B could fetch tasks using User A's plan-id if they manage to
> > access
> > > > >     those logs. Relying solely on table-level access for
> > authorization
> > > > might
> > > > >     not be sufficient to prevent this; we likely need stricter access
> > > > controls
> > > > >     tied to the plan itself.
> > > > >     -
> > > > >
> > > > >     *Modeling the Planner and Delegation Interface:* Because the
> > > > interface
> > > > >     for the delegation service isn't finalized yet, we need to ensure
> > > > it's
> > > > >     defined in a way that allows it to seamlessly provide the same
> > > > information
> > > > >     as the local service. I realize this starts to cross over into
> > > > Low-Level
> > > > >     Design (LLD), so I'm perfectly fine with hashing out the exact
> > > > >     implementation details during the PR review process.
> > > > >     -
> > > > >
> > > > >     *Tasks Endpoint Optimization (Without Delegation):* We should
> > look
> > > > into
> > > > >     modeling each planTask to correspond to a specific manifest. Even
> > > > though
> > > > >     we would have to open the manifest list more than once, it would
> > > > reduce the
> > > > >     memory footprint overall. Eric, Yufei, and I have discussed this
> > in
> > > > the
> > > > >     past, so I’d love to get your thoughts on incorporating it here.
> > > > >
> > > > > Looking forward to it.
> > > > >
> > > > > Best regards,
> > > > >
> > > > > Prashant Singh
> > > >
> > >
> >

Reply via email to