Repository navigation
Spec (draft): Record the storage configuration of every table and view, with default snapshots and a table property - #6232
Draft
sririshindra wants to merge 41 commits into
Draft
sririshindra wants to merge 41 commits into
sririshindra wants to merge 41 commits into
Conversation
Add the API contract for storage configurations as catalog-scoped entities, spec only: - Management API: create, get, list (paginated) and delete storage configurations under a catalog. Storage configurations are immutable. - Catalog API: create, remove and list storage mappings, which map the fully qualified name of a namespace or table to a storage configuration, and create a namespace or table on a storage configuration with the Iceberg request and response bodies. - Clarify StorageConfigInfo.storageName. A mapping can only be created or removed while its namespace or table does not exist, so an existing object always keeps the storage configuration it was created with. The management operations answer 501 until implemented; the catalog API operations are not served yet. No existing schema changes shape.
- State that the catalog's own storageConfigInfo can still be changed with updateCatalog, and that Polaris does not check cloud-side access of a storage configuration's identity. - Restate the rename rules as one rule that covers tables with and without their own mapping, and say that storage configurations are compared by identity. - Say which creates a mapping applies to (staged create, registerTable), that views inside a mapped namespace use its storage configuration, and that only namespaces and Iceberg tables can have a mapping. - Say that undoing a mapping after a failed create-on-configuration is best effort, and that the mapping privileges are always required. - Clarify where baseLocation applies, that a table path has at least two elements, and add a paragraph break to storageName. - List storage-mappings-api.yaml in spec/README.md.
…pings - Name the mapping privileges after the policy ones: STORAGE_CONFIGURATION_ATTACH and STORAGE_CONFIGURATION_DETACH on the storage configuration, with NAMESPACE_/CATALOG_ATTACH_STORAGE_CONFIGURATION and NAMESPACE_/CATALOG_DETACH_STORAGE_CONFIGURATION on the parent. - Accept Iceberg's Idempotency-Key header on the two create operations; a replay has no additional effects on the storage mapping either. - Deleting a catalog deletes its storage configurations and storage mappings.
- listStorageMappings lists one level at a time, like namespaces: the mappings directly inside `namespace`, or of the top-level namespaces without it. Listing every mapping to a storage configuration across the catalog is a separate mode of the same operation and requires CATALOG_MANAGE_METADATA, so mapped names are not visible to callers who can't list the namespaces they are in. - A view can't be renamed into a namespace that uses a different storage configuration, as for a table without its own mapping.
- A table with a mapping of its own takes it along on rename, also when the new name is already mapped to the same storage configuration: the old name is no longer mapped afterwards. Moving a mapping this way does not require the mapping privileges. - Generic tables inside a mapped namespace use its storage configuration, like Iceberg tables and views. - A storage configuration used by existing namespaces or tables can be deleted only after they are dropped and their mappings removed. - The CATALOG_ forms of the mapping privileges apply to top-level namespaces.
Dropping a namespace or table never removes a storage mapping, so the mappings left behind (target-exists is false) are removed explicitly: DELETE storage-mappings/orphans in the catalog API and DELETE storage-configurations/orphans in the management API, both with a dry-run mode. Also document that a rename can't bypass the attach and detach privileges, that a failed combined create leaves an orphan mapping, and reserve the storage configuration name "orphans". The storage mapping models are now generated for the catalog service, with serialization tests.
…cleanup The orphan cleanup removes orphan mappings (the target was dropped) by default and, with include-pending, also pending ones (the target never existed). Mappings expose target-ever-existed to tell them apart. Storage configurations expose everReferenced, and the cleanup can skip those that were never referenced. Both cleanups are paginated, and the mapping cleanup requires the privileges of removing each mapping, including STORAGE_CONFIGURATION_DETACH on the mapped configurations.
The allowedLocations of a storage configuration must not overlap another catalog or another catalog's storage configurations, and creating or updating a catalog is checked against them too. A storage configuration may name any cloud account or tenant and any supported storage type. The limits updateCatalog puts on changing the catalog's storageConfigInfo do not apply, so whoever holds STORAGE_CONFIGURATION_CREATE chooses the cloud identity. A response always holds all the settings in effect. Define a pending mapping the way target-ever-existed does: the target has not existed since the mapping was created.
Say that storageConfigInfo.storageName selects the server-side credentials of a storage configuration, what happens without it and when it can't be resolved, and that locations must match the storage type. The round trip tests now carry storageName for S3, Azure and GCS.
A storage configuration always honors storageName, even on a server that doesn't use the name of a catalog's own storageConfigInfo. The rules cover S3, Azure and GCS; FILE has no credentials and ignores the name. The error for an unresolvable name doesn't say why, and no API lists the names a server knows. Whoever can create a storage configuration chooses the server-side credentials. Changing the credentials behind a name on the server takes effect without changing the storage configuration, which is how they are rotated.
A per-level listing of storage mappings leaves out table mappings unless the caller also has TABLE_LIST on the namespace. Rename the list filter to storage-configuration-name, the style of the Polaris catalog API. State where a namespace or table with its own mapping is placed under baseLocation, and that the location rules compare with those locations.
…s locations Creating a storage configuration stays a static check, because access is often granted only after it exists. validateStorageConfiguration calls the cloud provider on request and reports each location, with an optional write check. Also leave namespace mappings out of a listing for callers who can't list namespaces, as for tables, and state what the orphan cleanup response names.
- 409 responses describe any conflict with the current state of the catalog, giving the previous reason only as an example. - The parameters of the new management paths (catalog name, storage configuration name, page token, page size) are defined once under components/parameters and referenced from the paths. - Authorization is no longer described in the spec; the privileges come with the server code. Behavior a client can observe, such as listings leaving out mappings the caller may not see, is described without privilege names. - The validate operation, its checkWrite parameter and its result schemas are removed from this PR and will be proposed separately.
New Polaris list operations either reference the Iceberg REST Catalog pagination definitions or define their own. The Iceberg definitions require a server to return all results when a request has no pageToken, which defeats the purpose of paginating, and per-operation copies drift apart. Add spec/polaris-pagination.yaml with one pageToken/pageSize parameter pair and a page token schema, usable from both the catalog and the management APIs. Its rules: any response may be paginated, neither parameter is needed to start, the server decides the page size, and a server may return everything in one response. Each response names the token field in its own API's style. No operation references the file yet. Existing operations keep their current definitions.
# Conflicts: # spec/generated/bundled-polaris-catalog-service.yaml # spec/polaris-catalog-service.yaml
The storage mapping lists referenced the Iceberg REST Catalog pagination definitions, which require a server to return all results when the request has no pageToken. That contradicted the operations' own description, which says results are paginated. The management lists had their own pageToken/pageSize parameters. Reference spec/polaris-pagination.yaml for both, so every list in this spec follows the same rules.
deleteOrphanStorageConfigurations and removeOrphanStorageMappings asked the server to delete a set it computes at request time, so a client could not know what a call would delete, and the promised atomic page is not something the persistence layer offers. Remove both, with their dryRun, skipNeverReferenced and include-pending parameters. A client now finds what to clean up with a list filter and deletes one item at a time: - listStorageConfigurations takes a `referenced` filter; a storage configuration is in use while a storage mapping references it, which is what deleteStorageConfiguration refuses on; - listStorageMappings takes a `target-exists` filter; - removeStorageMapping also removes a mapping whose parent namespace has been dropped. With the bulk cleanups gone, the reserved name `orphans`, the `everReferenced` field and the `target-ever-existed` field (pending versus orphan mappings) have no remaining use and are removed too.
Choosing which storage configuration a namespace or table uses is an
administrative decision, like a catalog's own storageConfigInfo, and
clients that work with tables don't need to see it. The mapping
operations were in the catalog API, next to the engine-facing
endpoints, while the storage configurations they reference were in the
management API.
Move listStorageMappings, createStorageMapping and removeStorageMapping
to the management API under /catalogs/{catalogName}/storage-mappings,
next to the storage configurations, so creating a configuration and
mapping a name to it are one workflow in one API. The schemas use the
management API's camelCase JSON, the management API's response style
and the shared Polaris pagination definitions, and no longer reference
the Iceberg REST Catalog spec. Their models are now generated in the
management model module, and the serialization test moves with them.
The two operations that create a namespace or table on a storage
configuration stay in the catalog API, because they take and return
the Iceberg REST bodies, vended credentials included. Their file is
renamed to storage-configurations-api.yaml, with the tag "Storage
Configuration API", since it no longer holds any mapping operation.
"The name of a storage configuration in the catalog" could be read as a storage configuration being part of the catalog object or its properties. A storage configuration is its own resource; the name is only unique within its catalog. Say that.
A namespace holds no data of its own, so its storage mapping is really a default for what is created in it. Forbidding changes to it while the namespace exists was only needed because tables inherited their namespace's storage configuration when they were loaded, so changing the namespace would have moved existing tables. Each Iceberg table, view and generic table now keeps the storage configuration it was created on for as long as it exists. A namespace mapping only decides what is created afterwards: - it can be created, replaced or removed while the namespace exists; - an object created inside a namespace without a mapping of its own uses the mapping of the nearest enclosing namespace that has one, as it is at the time of the create, or else the catalog's own storageConfigInfo; - existing objects keep their storage configuration and existing namespaces don't move. Table mappings keep the existing rule: created and removed only while the table does not exist. Because the storage configuration now travels with the object, a table or view without a mapping of its own can be renamed into any namespace. A rename onto a name mapped to a different storage configuration is still refused. Without an explicit location, an object created inside a namespace goes under the namespace's location if that location is inside the storage configuration's allowedLocations, and otherwise under the storage configuration's baseLocation (the catalog's default-base-location for the catalog's own storageConfigInfo), so a re-mapped namespace does not send new tables outside the allowed locations. A storage configuration is in use, and can't be deleted, while a mapping references it or an existing object was created on it. createNamespaceOnStorageConfiguration still refuses a name that is mapped to a different storage configuration.
The deleteCatalog description said the catalog must be empty and then that its storage configurations and mappings are deleted with it, which reads as a contradiction. State the actual rule instead: no namespaces, and no catalog roles other than catalog_admin, which is deleted with the catalog today. Storage configurations and storage mappings go the same way. Mappings can't block the delete because they remain after their namespace or table is dropped.
The two rejection tests only checked that something was thrown, so an unrelated exception would also have passed. Assert the Jackson exception type and that the message names the field that failed: an unknown target type gives InvalidFormatException, a missing storageConfigurationName gives MismatchedInputException.
The text said that for a staged create the mapping in place at commit counts. But the credentials of a staged create are vended at staging, and the engine writes its data with them before the commit, so deciding at commit could record a table on a different storage configuration than the one its data was written with. Choose the storage configuration at staging instead, the same moment as for a direct create, and create the table on it at commit. The commit is refused with 409 if the storage configuration the name would get has changed in between, or if the server no longer keeps the staged create. This applies equally to table mappings, namespace mappings and the catalog's own storage configuration. The create-on-configuration shortcut keeps supporting stage-create under the same rule.
Say that the commit of a staged create checks the location against the storage configuration chosen at staging again, that a change means the name resolves to a different storage configuration by identity (editing the catalog's own storageConfigInfo is not one), and describe the refusal for a staging the server can no longer match by its effect rather than by a mechanism. That refusal does not apply while a catalog has no storage configurations, so such catalogs behave as before. Also say that the nearest mapped namespace is taken at staging, and that only a successful staging keeps a mapping created by the shortcut.
Storage mappings become the record of which storage configuration an object uses, instead of something only consulted at create time. - A mapping is explicit (created by createStorageMapping or by a create on a storage configuration) or automatic (recorded by the server for an Iceberg table or view created on its namespace's storage configuration or on the catalog's own storageConfigInfo). StorageMapping gets a required `origin` field, and a target can be a view, which only automatic mappings have. - Once a catalog has a storage configuration, a table or view created on the catalog's own storageConfigInfo is created on a snapshot of it: a storage configuration the server creates from the current settings and reuses while they are the same. Snapshot names start with an underscore, which is reserved. Later edits of storageConfigInfo no longer reach tables and views created on an earlier snapshot. - Automatic mappings move with their table or view on rename and are removed when it is dropped. Explicit mappings stay after a drop, as before. removeStorageMapping only removes explicit mappings. - listStorageMappings lists explicit mappings by default; the new `includeAutomatic` parameter adds automatic ones. - A storage configuration is in use while any mapping, explicit or automatic, references it.
With storage mappings as the record of which storage configuration an object uses, a staged create records its choice at staging, for the staged table, and the commit records the mapping for the table's name. There is no expiry: Iceberg REST has no way to abort a staged create, so nothing tells the server that a staging was abandoned. - Changing a namespace mapping or the catalog's own storageConfigInfo between staging and commit no longer refuses the commit; the table is created on the storage configuration its data was written with. - The commit is refused (409) if the name has an explicit mapping to a different storage configuration by then, if the chosen storage configuration has been deleted, or if the server can't match the commit to its staging. - Concurrent stagings of one name keep working as today: each has its own choice, and the first commit wins. - createTableOnStorageConfiguration with stage-create: the mapping is listed only once the commit creates the table.
An Iceberg REST createTable request, direct or staged, can name a storage configuration in the table property `polaris.storage-configuration`. It has the same effect as createTableOnStorageConfiguration, which stays: the table name is mapped explicitly and the table is created on that storage configuration. A name already mapped elsewhere is refused (409), an unknown storage configuration is a bad request. Polaris removes the property before it builds the table metadata, so it never reaches the metadata file or a loadTable response, and table commits still can't set `polaris.` properties. createTableOnStorageConfiguration says it is the same as a create with the property, and refuses a request that also sets the property to a different storage configuration. Also rewraps the storage mapping description after the previous commits.
…talog, list automatic mappings by default Dropping a table or view removes its mapping, explicit or automatic; namespace mappings stay. Snapshots of the catalog default no longer depend on a storage configuration having been created. A staged commit is also refused if the explicit mapping the name had at staging was removed. listStorageMappings lists everything by default; excludeAutomatic limits it to explicit mappings.
… it was at staging, and limit mappings to INTERNAL catalogs Also corrects the deleteCatalog and listStorageMappings text for mappings that now go with their table.
Dropping a namespace leaves the mappings of namespaces that don't exist, not only those of tables never created. Objects created on a snapshot are placed with the catalog's default-base-location, as on the catalog's own storageConfigInfo. The StorageConfiguration description now says that storage configurations and mappings apply to INTERNAL catalogs only. Long and ragged lines are rewrapped.
4 of 6 tasks
This branch has not been deployed
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.
Draft follow-up to #5943. Not for review yet.
This PR builds on #5943 and changes its spec to follow the implementation plan I posted on dev@
(email), so that reviewers of
#5943 can see where the design is going. It stays a draft until that thread settles, and it will
change to follow what dev@ decides. #5943 itself stays as it was reviewed.
The branch contains #5943, so until #5943 merges GitHub shows the changes of both here. Only the
commits after #5943's head (
3094d3b028) are new(compare).
They change
spec/polaris-management-service.yml,spec/polaris-catalog-apis/storage-configurations-api.yaml, the generated bundle andStorageMappingSerializationTest.What this changes in #5943
explicitorautomatic. In Spec: Add storage configuration and storage mapping APIs (beta) #5943 onlyexplicitly mapped namespaces and tables have one.
StorageMappinggets a requiredoriginfield,and
StorageMappingTarget.typegetsview, which only automatic mappings use.storageConfigInfoare created on a snapshot ofit. In Spec: Add storage configuration and storage mapping APIs (beta) #5943 they follow later
updateCatalogchanges. Names starting with_are reserved forsnapshots, and
listStorageConfigurationslists snapshots too.stays after the drop. This reverses what I argued in Spec: Add storage configuration and storage mapping APIs (beta) #5943's review, that a table mapping has to
survive drops so that a pipeline that drops and re-creates a table through plain Iceberg REST
lands on the same storage every time. I now prefer removing it: nothing is left behind to clean
up, and explicit and automatic mappings behave the same. The dev@ email asks about this
(question 1), so it may change again. Namespace mappings still stay when their namespace is
dropped.
polaris.storage-configuration, on an IcebergcreateTable(direct orstaged), as a second way to create on a storage configuration. Spec: Add storage configuration and storage mapping APIs (beta) #5943 has none.
configuration than at staging, also when only a namespace mapping changed, and when the server can
no longer tell what was chosen at staging, for example after a time limit the server sets. Here
the choice is recorded for the staged table at staging, changes to namespace mappings or to
storageConfigInfoin between don't affect it, and the commit is refused with 409 unless thename's explicit mapping is the same as at staging. The spec sets no time limit.
deleteStorageConfigurationis now "referenced by any mapping, explicit orautomatic". In Spec: Add storage configuration and storage mapping APIs (beta) #5943 it is "referenced by a mapping, or used by an existing Iceberg table, view or
generic table". Generic tables get no mappings, so they no longer count.
listStorageMappingslists automatic mappings too, and takesexcludeAutomatictolist only explicit ones.
createStorageMappingandremoveStorageMappingwork on explicitmappings only, so a
viewtarget is a bad request for both.rename is refused only onto a name with an explicit mapping to a different storage configuration.
apply to INTERNAL catalogs only.
deleteCataloggives the updated reason why mappings don't prevent the deletion.The binding model with this change
mapping made with
createStorageMapping, with one of the two create operations of the catalogAPI, or with the table property is explicit. When an Iceberg table or view is created without an
explicit mapping of its own, Polaris records an automatic mapping to the storage configuration it
was created on.
exists. Polaris writes a table's first metadata file at create time, so the choice has to be made
before the table exists, and it can't change afterwards without making the files the table
already has unreadable.
storageConfigInfo. Such a table or viewis created on a snapshot of
storageConfigInfo: a storage configuration the server makes with thesettings
storageConfigInfohas at that moment, and reuses for later creates while those settingsstay the same. This applies to every INTERNAL catalog, not only to catalogs that have storage
configurations of their own. So editing
storageConfigInfowithupdateCatalogonly affects whatis created afterwards, and the tables and views created before snapshots existed, which have no
mapping and keep following it as today. A snapshot has no
baseLocation(the catalog'sdefault-base-locationtakes its place), usesstorageNamethe way the catalog's ownstorageConfigInfodoes, and is not checked when it is made. Otherwise it is listed, read, mappedand deleted like any other storage configuration.
created, replaced or removed at any time. An object created inside a namespace without an explicit
mapping of its own uses the mapping of the nearest enclosing namespace that has one, as it is at
the time of the create, or else the catalog's own
storageConfigInfo. Changing a namespacemapping never changes an existing object or moves an existing namespace. Namespaces never get
automatic mappings, so a namespace mapping keeps applying to what is created in it later.
giving it a different name. Examples: one table with personal data in a separate, locked-down
account; data residency per table; a table registered from another account or cloud; migrating a
namespace to other storage one table at a time. Putting such a table in its own namespace would
change its identifier, which breaks every query that uses it, and take it out from under the
namespace's grants. An explicit table mapping can be created only while the table doesn't exist:
ahead of the table, or by the create itself. Dropping the table removes its mapping, explicit or
automatic, so a table created again under the same name is created as if it had never existed. A
pipeline that drops and re-creates a table maps it again, or sets the table property below.
createTable, direct or staged, can setpolaris.storage-configurationto a storageconfiguration's name. It has the same effect as
createTableOnStorageConfiguration: the name ismapped explicitly and the table is created on that storage configuration. The request is refused
(409) if the name already has an explicit mapping to a different storage configuration, and is a
bad request if the catalog has no storage configuration with that name. So a Spark
CREATE TABLE … TBLPROPERTIES (…) AS SELECTcan use it without a Polaris-specific call. Polarisremoves the property before it creates the table metadata, so it is never part of the table's
metadata or properties, and table commits still can't set
polaris.properties. AcreateTableOnStorageConfigurationrequest that also sets the property must name the samestorage configuration, or it is a bad request.
chosen when Polaris checks the location and hands out credentials, which for a staged create is
at staging. Polaris records that choice for the staged table, and the commit creates the table on
that same storage configuration and records the mapping for its name. Changing a namespace
mapping or the catalog's
storageConfigInfoin between doesn't affect the staged table. Thecommit is refused with 409 unless the name's explicit mapping is the same as at staging (none
both times, or the same storage configuration both times). It is also refused if that storage
configuration has been deleted, or if the server can't match the commit to its staging. Several
staged creates of one name can be in progress at once, as today, and the first commit creates the
table. Iceberg REST has no way to abort a staged create, and the spec sets no time limit. A
staging that is never committed is never listed, and doesn't keep its storage configuration from
being deleted.
location, and its mapping moves with it. A rename onto a name explicitly mapped to a different
storage configuration is refused.
under the storage configuration's
baseLocation. An object created inside a namespace goes underthe namespace's location if that location is inside the storage configuration's
allowedLocations, and otherwise underbaseLocation(for the catalog's ownstorageConfigInfoand its snapshots, the catalog'sdefault-base-location).Dropping a namespace doesn't remove its own mapping or the explicit mappings inside it, which can
only be those of namespaces that don't exist and of tables that were never created.
listStorageMappingscan filter ontargetExists,listStorageConfigurationsonreferenced,and a client removes or deletes what it no longer wants one item at a time. A storage
configuration can't be deleted while any mapping, explicit or automatic, references it.
the nearest enclosing namespace that has a mapping, or else on the catalog's own
storageConfigInfo.Authorization
As in #5943, authorization is not part of the spec. The intended model follows policies: managing
storage configurations, using one in a mapping, and managing the mappings of a namespace are
separate privileges, and creating or removing a mapping needs both the storage configuration side
and the namespace side. The two catalog API operations that create on a storage configuration, and
an Iceberg
createTablewith thepolaris.storage-configurationproperty, need whatcreateStorageMappingneeds plus what the namespace or table create needs, also when the name isalready mapped to that storage configuration; the server checks this in one place for all three. A
create that inherits a storage configuration, and so gets an automatic mapping, needs only the
create privilege.
Behavior after this PR
Spec only, like #5943: nothing new is served, and the new management operations answer
501 Not Implemented. The server side comes in later PRs, behind a feature flag that is off by
default, as described in the dev@ email.
Testing
StorageMappingSerializationTestcovers the neworiginfield and aviewtarget (an automaticmapping to a snapshot), and still checks that an unknown target type is rejected.
Checks run locally on this branch:
./gradlew format,rat,:polaris-api-management-model:check,:polaris-api-management-service:check,:polaris-api-catalog-service:check,:polaris-api-iceberg-service:compileJava,:polaris-runtime-service:compileJavaandcompileTestJava, andmake spec-bundle-verify(thecommitted bundle is current). The full suite was left to CI.
Checklist
changelog.d/(if needed, seechangelog.d/README.md): no; spec onlysite/content/in-dev/unreleased(if needed): no; docs come with the implementationCONTRIBUTING.md)