Repository navigation
feat(storage): commit a new schema or partition spec to an Iceberg table - #906
Merged
Merged
Conversation
…ics.update_table # Conflicts: # packages/Storage/Storage/IcebergCatalog.cs # packages/Storage/Storage/Interfaces/IIcebergCatalog.cs
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.
Summary
A caller can commit a new current schema, a new default partition spec, or both, to an Iceberg table. They can optionally guard the commit against concurrent changes since the metadata they started from.
Capability:
storage.analytics.update_table- Update Iceberg Table. No capability spec exists; the contract comes from the supabase/storage Iceberg commit route and the Iceberg RESTCommitTableRequest.Public API
Behavior
POST {storageUrl}/iceberg/v1/{bucket}/namespaces/{namespace}/tables/{table}, service-role key.{"requirements":[…],"updates":[…]}. Both arrays are always sent, because Storage's route requires them.Schemabecomesadd-schema {schema}, thenset-current-schema {"schema-id":-1}. In the Iceberg REST spec, -1 means the schema added by the same commit.PartitionSpecbecomesadd-spec {spec}, thenset-default-spec {"spec-id":-1}.BasedOnis set:assert-table-uuidassert-current-schema-idandassert-last-assigned-field-idassert-default-spec-idandassert-last-assigned-partition-idBasedOn,requirementsis empty and the last writer wins. Empty changes are sent as is; the catalog judges them.metadata-location+metadata) asIcebergTableMetadata, with the same mapping as create and load.SupabaseStorageException, with the Iceberg error type inCode:CommitFailedException: a requirement failedNoSuchTableException,NoSuchNamespaceExceptionorNoSuchCatalog(ReasonNotFound)AccessDeniedCommitStateUnknownExceptionArgumentNullException./..table name or namespace, throwsArgumentExceptionDeviations from supabase-js
BasedOn. iceberg-js exposes the rawrequirementsandupdatesarrays (23 update kinds and 8 requirement kinds). Properties, sort orders, snapshots and locations are out of scope, and more can be added later without breaking callers.Idempotency-Keyheader: Storage ignores it.Tests
UpdateTableApprovalTestsBasedOnrequirements, empty commitUpdateTableContractTestsUpdateTableTestsNo E2E: the local stack does not serve the Iceberg routes. Storage registers them only with
ICEBERG_ENABLED, which the CLI does not set locally, and table operations proxy to an external Iceberg REST catalog.Changed-line coverage: 100% (68 lines). Mutation: 37/37 on the changed files (36 killed, 1 timeout on the
ConfigureAwait(false)mutant), 0 survivors.Notes
assert-current-schema-idandassert-default-spec-idtake the ids fromBasedOn.CurrentSchema.SchemaIdandBasedOn.DefaultPartitionSpec.SpecId. Metadata the SDK decodes always carries both. Metadata a caller builds by hand without them sendsnull, and the catalog rejects it.SchemaId/SpecIdon the wire when the caller set one (for example by copying the current schema withwith). The Iceberg REST catalog assigns its own ids, so the value is informational.