Skip to content

Add the Directories REST API specification and documentation - #5927

Open
jbonofre wants to merge 9 commits into
apache:mainfrom
jbonofre:directory-spec
Open

jbonofre wants to merge 9 commits into
apache:mainfrom
jbonofre:directory-spec

Conversation

@jbonofre

@jbonofre jbonofre commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

This is the first of three PRs split from #4613, as discussed during the community meeting, to make the review easier:

  1. This PR: OpenAPI specification and documentation
  2. Add the Directory entity, REST endpoints and DirectoryScanService SPI #5928: Directory entity, REST endpoints and DirectoryScanService SPI
  3. Add a simple directory scan service #5929: simple directory scan service

Directories allow users to point Polaris at a location/prefix on an object store (S3, GCS, Azure) containing objects (including unstructured data like images, videos, documents) and track the objects in an Iceberg table with object-level metadata (location, size, content type, checksum, last modified, etc.).

Changes

  • spec/polaris-catalog-apis/directories-api.yaml: new Directory API under /polaris/v1/{prefix}/namespaces/{namespace}/directories (list, create, load, drop and scan), referenced from polaris-catalog-service.yaml.
  • StorageAccessConfig moves from generic-tables-api.yaml to a new common-schemas.yaml, so generic tables and directories share the same schema. The generic tables API itself is unchanged.
  • spec/generated/bundled-polaris-catalog-service.yaml is regenerated with spec/bundle.sh.
  • site/content/in-dev/unreleased/directories.md: user documentation for directories.

No server code is generated from the new API in this PR: DirectoryApi is added to the generated APIs in the next PR, together with its implementation.

Notes for reviewers

Checklist

@dimas-b dimas-b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for pushing this feature, @jbonofre !

I'm generally reposting my comments from #4613.

LGTM except for pagination parameters 😅

description: Return all directory identifiers under this namespace
operationId: listDirectories
parameters:
- $ref: '../iceberg-rest-catalog-open-api.yaml#/components/parameters/page-token'

@dimas-b dimas-b Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I disagree with how pagination is defined in IRC, specifically:

Servers that support pagination must return all results in a single response with the value
of `next-page-token` set to `null` if the query parameter `pageToken` is not set in the
request.

The idea of clients forcing servers into returning all data is against the very premise of pagination.

We are fixing this in our IRC API impl. in #5282 and #5553. I think we should do proper pagination in the Directories API upfront:

  • Clients should always expect that a response may be paginated
  • Clients do not need to set either the page-token or page-size on the initial request to initiate pagination. The server decides.
  • The server decides on actual page sizes. The can be smaller than the page-size hint.
  • A server may choose not to support pagination and return all data in one chunk (but Polaris will support pagination, I assume).

Related discussions:

https://lists.apache.org/thread/k81ptyktdbdf8gynncgk3o04mqt85zyk
https://lists.apache.org/thread/mmqllcbt2lfsrq571cfwbymgfwoxqdf0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 on doing proper pagination in the Directories API from the start.


---
paths:
/polaris/v1/{prefix}/namespaces/{namespace}/directories:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking: this path prefix interleaves with other Polaris API (e.g. Generic Tables, Policies...). Since endpoints are distinct, it is not a problem. However, it makes separating APIs more difficult.

The v1 prefix is shared and it is usually perceived as the "API root".

There is no static prefix just for the directories API, which can complicate network routing if someone wants to segregate traffic by API.

I know this fit the existing pattern, so my comment is non-blocking 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The intent is to align with other Polaris APIs.

I'm fine to change that but it would be probably a bit confusing for users. A possible alternative would be to hook in Generic Tables but I don't think it's a great idea from a semantic perspective.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No worries, this is more of an opinion on my part (non-blocking).


---
paths:
/polaris/v1/{prefix}/namespaces/{namespace}/directories:

@flyrain flyrain Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a new endpoint for the directory? It is a sub type of generic table. I think we could follow the way we introduce Delta/Hudi/Paimon.

@jbonofre jbonofre Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's semantically different: my take on Generic Table is for non-Iceberg table.
As Inventory is a Iceberg table and Directory is a new "feature", I think it makes more sense to have dedicated endpoint.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a directory table is essentially a type of generic table. They share the same location management requirements, including but not limited to base location, overlap checking, and credential vending.

This makes directory tables quite different from other entities, such as policies and tags, which don't require storage.

I'm not sure we need to reinvent what we've already implemented for generic tables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm still in favor of different endpoints because:

  • filter and scan-schedule are typed. As a generic table, they would become untyped string properties.
  • There's a scan action, which generic tables don't have.
  • What users query is an Iceberg table (__inventory), and generic tables are defined as non-Iceberg.
  • base-location points at existing external data the catalog doesn't own.

If the implementation PR (phase 2) can reuse the generic-table code for location validation, overlap checks and credential vending, keeping the API separate doesn't mean rebuilding everything.

Should a directory be allowed over a prefix that overlaps an existing table's location? Generic table rules would reject that, and it's plausible use case.

So, I'm still in favor of Directory endpoint, not generic table.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a separate Directories endpoint makes sense.

  • It defines a specific and focused contract.
  • It defines functionality beyond the scope of Generic Tables.
  • It evolves independently of the Generic Tables API.
  • It allows downstream projects to elect implementing Directories with or without the broader Generic Tables.

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanx @jbonofre for working on this, dropped few suggestions

@dimas-b

dimas-b commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

from CI: ERROR: bundled OpenAPI spec is out of date. Please run 'make spec-bundle' and commit the changes.

…feature flag

- Define a local DirectoryPageToken schema so the Directories API documents
  its own pagination semantics instead of inheriting the IRC PageToken ones.
- Rename the local page-token and page-size parameters to avoid colliding
  with the IRC components in the bundled spec.
- Remove scan-schedule: Polaris does not act on it, and scanning services
  decide when to re-scan.
- Move the ENABLE_DIRECTORIES feature flag to the implementation PR, as it
  does not gate anything yet.
- Regenerate the bundled OpenAPI spec.
dimas-b
dimas-b previously approved these changes Nov 4, 2026

@dimas-b dimas-b left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the update, @jbonofre . Current API spec LGTM 👍

My comments are optional. If you choose to apply them, I think a follow-up PR would work too.

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Nov 4, 2026
ayushtkn
ayushtkn previously approved these changes Nov 4, 2026

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanx @jbonofre for the update, my comments are addressed, changes LGTM

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot for working on it, JB!

…ing and page token

- Remove the scan endpoint: the scan execution and inventory ownership
  model with external scanning services needs to be defined first.
- Remove the Polaris-Directory-Access-Delegation header and the
  storage-access-configs response field, as credential vending for the
  directory base-location is not supported yet. This also reverts the
  StorageAccessConfig move to common-schemas.yaml.
- Use an inline schema for the pageToken query parameter.
- Regenerate the bundled OpenAPI spec.
@jbonofre
jbonofre dismissed stale reviews from dimas-b and ayushtkn via 174a037 November 5, 2026 09:04

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks so much for working on it @jbonofre ! Left comments.

…e and beta label

- Mark each Directories API operation as beta in the spec, as done for the
  semantic-model API.
- Move filter into a new scanner-config object (DirectoryScannerConfig), so
  more scanner options can be added later without new top-level fields.
- Return the optional inventory-table identifier when a directory is loaded,
  absent if the inventory table does not exist.
- Document that the directory table is a snapshot as of the last scan and can
  lag behind the object store.
- Make last_modified required in the directory table schema.
- Explain why checksum_algorithm is set per object.
- State that credential vending for the base-location objects is planned.
- Regenerate the bundled OpenAPI spec.

@ArnabKarmakar1108 ArnabKarmakar1108 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this! The docs LGTM! Ive dropped a few comments on the next two PRs and since they are not part of 1.9.0 those can be addressed later.

dimas-b
dimas-b previously approved these changes Nov 9, 2026
@sririshindra

Copy link
Copy Markdown
Contributor

FYI: following the pagination discussion here and on #5943, I opened #6028 (draft). It adds shared pagination definitions for Polaris APIs in spec/polaris-pagination.yaml: the pageToken/pageSize query parameters and a page token schema, with the same rules as directory-page-token and DirectoryPageToken here. Mentioning it in case it's useful for the Directories API.

@flyrain flyrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot for working on it, JB! Post some comments.

Comment on lines +44 to +45
- $ref: '#/components/parameters/directory-page-token'
- $ref: '#/components/parameters/directory-page-size'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a blocker: I'd suggest to use one common pagination schema cross Polaris end points, if we are not using IRC pagination schema. We now have different pagination schema in different end points. This fragmentation is unnecessary. I'm OK with a followup. Can we file an issue for this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. #6028 adds shared pagination definitions for the Polaris APIs (spec/polaris-pagination.yaml), with the same rules as directory-page-token and DirectoryPageToken here. Once it lands, I will switch the Directories API to the shared definitions in a follow-up.

**Beta:** The Directories API is under active development and may change in a
backward-incompatible way.

Create a directory under the given namespace, and return the created directory information as a response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we create the inventory table by default? If not, how do we return the inventory table identifier? If yes, does it involve the first-time scan?

Can clients control the behavior(whether to create the inventory table)? For example, a user may just need a simple managed volume without the inventory table, which is a reasonable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, the inventory table is always created with the directory, empty, in the same namespace, and the create response returns its identifier in inventory-table. Creating a directory doesn't trigger a scan: Polaris doesn't scan, the external scanning services populate the inventory table. I clarified this in the createDirectory description and in the doc.

I would not add an option to skip the inventory table now. The inventory table is what makes the objects discoverable through Iceberg. Without it, a directory is only a registered location, as Polaris doesn't vend credentials for the base-location yet. As inventory-table is already optional in Directory, we can add this option later (for the managed volume use case) without breaking clients.

WDYT?

description: The name of the directory. It is used in REST endpoint paths and is used, followed by the `__inventory` suffix, as the name of the corresponding Iceberg table.
base-location:
type: string
description: The external object store location to use as a root for scanning objects (e.g. s3://bucket/path/). This is where the scanned objects live, not the location of the Iceberg inventory table, which is assigned by Polaris.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it mean we never allow clients to specify the inventory table location?
In that case, it has to locate under the ns where the directory table exists, which becomes tricky when we allow the base-location be outside of the current namespaces, since it may select a different storage configurations. For example, we may have to vend credential for aws s3 and azure when it comes to the phase we vend credentials for both directory table and its inventory table.

If we allow clients to specify location, it actually hits the same problem.

I think a way to simplify the situation is to let the inventory table always co-locate with the directory base-location, the same parents is probably the easiest thing to do. WDTY?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, clients don't choose the inventory table location for now: Polaris creates the inventory table like any table in the namespace, at the default table location (under the namespace location).

I don't think the inventory table can end up with a different storage configuration than the base-location: the directory and its inventory table are in the same namespace, so they resolve the same storage configuration, and the base-location is validated against its allowed locations. Credential vending for both will go through the same storage configuration.

I'm not sure about co-locating the inventory table with the base-location:

  • inside the base-location, the scan would list the data and metadata files of the inventory table itself, and writing the inventory table would need write access to the base-location, which is often data that should only be read (for example a bucket written by another team or an ingestion pipeline).
  • next to the base-location (same parent), the parent may be outside the allowed locations (or not exist, for a bucket root), and the inventory table could collide with other data.

The default table location avoids these issues. If needed, we can add an optional inventory table location to the create request later, validated like a table location.

WDYT?

schema:
$ref: '#/components/schemas/LoadDirectoryResponse'

ListDirectoriesResponse:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this wrapper is not needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Which wrapper do you mean?

  • CreateDirectoryResponse in components/responses, which is the same as LoadDirectoryResponse (updateDirectory already references LoadDirectoryResponse directly)? I can remove it.
  • or the {"directory": ...} object of LoadDirectoryResponse? I would keep this one: it follows LoadGenericTableResponse, and leaves room to return the storage credentials for the base-location next to the directory in phase 2 without breaking clients.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

line 428 defines a ListDirectoriesResponse, which refers to line 401 with the same name. Do we need two schema for the same thing?

@jbonofre jbonofre modified the milestones: 1.9.0, 1.10.0 Nov 10, 2026
…d inventory table schema

- Document that creating a directory creates its empty inventory table without scanning
- Document that dropping a directory drops its inventory table without purge and never
  deletes the objects under the base location
- Describe the base location validation in the spec
- Add the inventory table schema and its compatibility rule to the spec

@orca-review-bot orca-review-bot 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.

Nice split. The spec is easy to read, and the beta label and the external-scanner model match the dev-list direction. Inline comments cover the contract choices that will be hard to change once #5928 builds on them: pagination, error types, how to clear a field on update, and the inventory table sitting inside the scanned prefix.

Comments that don't anchor to a line:

  • The PR description is stale. It mentions a scan endpoint, a StorageAccessConfig move to common-schemas.yaml (it's still in generic-tables-api.yaml), and docs for the ENABLE_DIRECTORIES/ENABLE_DIRECTORY_SCAN flags, and none of these are in the diff. It also doesn't mention the update endpoint. Can we refresh it?
  • directories.md lands in unreleased/ before the endpoints exist. If a release is cut between this PR and #5928, users get docs for an API that returns 404. Can we hold the page, or merge the stack together?
  • There's no CHANGELOG entry, which is fine for spec only. Can we make sure the beta entry lands with #5928?
  • For #5928: since base-location reuses table-location validation, can we have tests for the allowed-locations check on create, the deny cases, and the __inventory name collision?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

UpdateDirectoryRequest:
type: object
description: >
Fields to update on a directory. Omitted fields are left unchanged.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"Omitted fields are left unchanged" means there's no way to remove a scanner-config or a filter once it's set. You'd have to drop and recreate the directory, which also drops the inventory table. Should an explicit null or {} clear the field? Can we say which one in the spec?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

example: "product-images"

schemas:
DirectoryPageToken:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Generic-tables and policies reuse the Iceberg page-token/PageToken, and this adds a second pagination contract to the same service. The main difference is that you don't need to send an empty token to start paging. If that's the reason, can we say so in the PR description? Otherwise, can we reuse the Iceberg parameter so the Polaris list APIs stay consistent?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

$ref: '../iceberg-rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse'
404:
description:
Not Found - NoSuchTableError, directory to load does not exist

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A missing directory is reported as NoSuchTableError. Clients that branch on the error type then can't tell "directory not found" from "table not found". The 409 at line 117 has the same problem. Is that the type the server will return in #5928, or should directories get their own error type while the API is still beta?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.


### Base location

The `base-location` is validated like a table location when the directory is created:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

base-location has to be inside the namespace location, and the inventory table is created in that same namespace. So if base-location is the namespace root, the inventory's own data and metadata files sit inside the scanned prefix, and a scanner will index them into the inventory table. This was one of the must-fix items on the dev list. Can we document how to avoid it (for example with an exclude filter), or require scanners to skip the inventory location?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

|-------|------|----------|-------------|
| `name` | `string` | Yes | The name of the directory. It is used in REST endpoint paths and is used, followed by the `__inventory` suffix, as the name of the corresponding Iceberg table. |
| `base-location` | `string` | Yes | The external object store location to use as a root for scanning objects; this is not the location of the Iceberg inventory table, which is assigned by Polaris (for example `s3://my-bucket/images/`, `gs://my-bucket/docs/`, or `file:///data/local/`). |
| `scanner-config` | `object` | No | Configuration for the scanning services, such as the filter that controls which objects are added to the directory table during a scan. See [Scanner configuration](#scanner-configuration). |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The spec also accepts properties on create, and the update section mentions it, but this table doesn't list it. Can we add a row?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

- When an engine loads the directory table with [credential vending]({{% ref "vended-credentials" %}}), Polaris
vends credentials scoped to the directory table location (its data and metadata files), as for any Iceberg
table. These credentials are not scoped to the directory `base-location`.
- Privileges on the directory or on the directory table (for example `TABLE_READ_DATA`) don't grant access to the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This mentions "privileges on the directory", but the page never says which privileges govern list/create/load/update/drop. Can we name them here, or say they'll be defined in #5928, so admins know what to grant?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants