Repository navigation
Service: Make default table/view locations unique - #4606
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes how Polaris derives managed table/view locations and how it handles client-specified locations, by introducing two new feature flags and enforcing new defaults in the Iceberg service layer.
Changes:
- Added
DEFAULT_TABLE_LOCATION_USE_UUID(default on) to append a random UUID suffix to managed table/view locations when no explicit location is provided. - Added
ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION(default off) and enforced rejection of client-specifiedlocation,SetLocation, andwrite.data.path/write.metadata.pathacross create/update paths (including commit-transaction). - Updated tests/fixtures and documentation/changelog to reflect the new flags and behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| site/content/in-dev/unreleased/configuration/config-sections/flags-polaris_features.md | Documents the two new feature flags and their defaults. |
| runtime/service/src/testFixtures/java/org/apache/polaris/service/TestServices.java | Pins location-related feature flags to legacy behavior for most tests unless explicitly overridden. |
| runtime/service/src/test/java/org/apache/polaris/service/catalog/Profiles.java | Forces legacy location behavior in the shared catalog test profile; relies on dedicated tests for new defaults. |
| runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergTableLocationUuidTest.java | Adds focused coverage for UUID default locations and default rejection of client-specified locations/write paths. |
| runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java | Enforces the client-specified location gate on create/update/replace and commit-transaction flows (and stage-create create path). |
| runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java | Implements UUID-suffixed managed location generation when the new default-location feature is enabled. |
| polaris-core/src/test/java/org/apache/polaris/core/config/PolarisConfigurationTest.java | Locks and asserts the production defaults for the two new flags. |
| polaris-core/src/main/java/org/apache/polaris/core/config/FeatureConfiguration.java | Defines the new feature flags, keys, config names, descriptions, and defaults. |
| CHANGELOG.md | Adds upgrade notes, breaking change notes, and new feature entries for the location behavior changes. |
| - Newly created tables and views now use a unique, unpredictable location by default: Polaris appends a random UUID to | ||
| the generated location (controlled by the `DEFAULT_TABLE_LOCATION_USE_UUID` feature flag, on by default). Caller-specified | ||
| locations are now rejected by default (controlled by `ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION`, off by default): this covers the | ||
| `location` field as well as the `write.data.path` / `write.metadata.path` properties, on create-table/create-view, | ||
| update-table/replace-view, and commit-transaction requests. |
| Existing tables and views are unaffected. To restore the previous behavior, set `polaris.config.default-table-location.use-uuid=false` and `polaris.config.allow.client-specified.table.location=true` (per realm or per catalog). | ||
|
|
||
| ### Breaking changes | ||
| - Create-table, create-view, update-table, replace-view, and commit-transaction requests that specify a location (the `location` field, a `SetLocation` update, or the `write.data.path` / `write.metadata.path` properties) are now rejected by default. Set `ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION` (`polaris.config.allow.client-specified.table.location`) to `true` to allow caller-specified locations. Federated catalogs, staged-create commits, and `register table` / `register view` (which supply a metadata location) are unaffected. |
|
Thanks for tagging. I will look into this later this weekend. |
There was a problem hiding this comment.
Thanks for this enhancement, @flyrain ! I support the idea of using randomized table locations in general.
Some impl.-specific comments below.
This this is a major behaviour change, I believe it deserves a mailing list discussion.
| throw new BadRequestException( | ||
| "Specifying a table or view location (%s) is not allowed; set %s to true to allow it.", | ||
| specifiedBy, FeatureConfiguration.ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION.catalogConfig()); |
There was a problem hiding this comment.
specifiedBy can be "location", leading the confusing message like Specifying a table or view location (location) is not allowed; [...].
| FeatureConfiguration.ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION, | ||
| getResolvedCatalogEntity())) { | ||
| throw new BadRequestException( | ||
| "Specifying a table or view location (%s) is not allowed; set %s to true to allow it.", |
There was a problem hiding this comment.
Re: set %s to true to allow it - if we disallow it for a reason, we should not suggest an "easy button" for by-passing this check. Instead users should read the docs and make a mindful decision, I think.
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
|
Not stale |
|
This is being discussed on ATM, I do not think we have a resolution for the concern about vended credential for long staged create operations 🤔 |
|
Hi folks, resolved comments. Please take another look. |
@dimas-b, IIUC, there is currently no solution for long staged create operations. Can you explain how this PR impacts a feature that doesn't exist today? |
|
@flyrain :
I'm not sure what you mean by "a feature that doesn't exist today", but my points about potential effects of this PR on end users are noted on Let's continue this discussion on Defaulting |
Tables and views created without an explicit location now get a unique, unpredictable suffix by default, so no two tables share a path prefix. This is controlled by the new DEFAULT_UNIQUE_TABLE_LOCATION_ENABLED feature flag (on by default); the suffix is generated in defaultWarehouseLocation, so existing tables/views are untouched. Set it to false to keep the legacy `<namespace location>/<table name>` layout for new tables. Caller-specified locations remain honored by default. Operators can set the new ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION flag to false to make Polaris manage all locations: that rejects a caller-supplied `location` field, a `SetLocation` update, and the `write.data.path` / `write.metadata.path` properties on create-table/create-view, update-table/replace-view, and commit-transaction requests. Staged-create commits, register table/view, and federated catalogs are unaffected. The new behavior is covered by IcebergTableLocationTest and PolarisConfigurationTest. The legacy layout is pinned (via the unique-location flag) in the shared unit-test profile, TestServices, the REST integration-test base, and the regression-test server, because the inherited Iceberg CatalogTests and the credential-scoping regression tests assert on deterministic locations. Also regenerates the feature-flags reference docs and updates the CHANGELOG.
…GE_PREFIX_ENABLED.
|
@dimas-b :
My point is that we haven't converged on a solution for long staged create operations yet. There are potential approaches that would not be affected by unique table locations, so I think it's a bit premature to conclude that this feature impacts that discussion. More generally, I agree that we should preserve backward compatibility by defaulting |
| polaris.features."ENABLE_CATALOG_FEDERATION": "true" | ||
| # Regression tests assert on deterministic table locations (e.g. direct S3 access scoped to | ||
| # `.../<table>/`), so keep the legacy layout instead of the unique-suffix default. | ||
| polaris.features."DEFAULT_UNIQUE_TABLE_LOCATION_ENABLED": "false" |
There was a problem hiding this comment.
This is the same as default now. So this override is not necessary.
| NAMESPACE, | ||
| name); | ||
| assertThat(normalizedLocation).startsWith(expectedPrefix); | ||
| assertThat(normalizedLocation.substring(expectedPrefix.length())).matches("[0-9a-f]{32}"); |
There was a problem hiding this comment.
This asserts only that the location has a suffix beyond the table name. It does not assert that the suffix is unique 🤷 It might be worth renaming the method to something like assertObjectStorageLocationFormat().
| // Keep the legacy default location layout so the shared catalog test suite keeps its | ||
| // historical behavior; the unique-location default is exercised by dedicated tests. | ||
| "polaris.features.\"DEFAULT_UNIQUE_TABLE_LOCATION_ENABLED\"", | ||
| "false", |
|
|
||
| public Builder config(Map<String, Object> config) { | ||
| this.config = config; | ||
| this.config.putAll(config); |
There was a problem hiding this comment.
It was needed when TestServices preloaded the legacy location defaults. Those defaults were removed after changing the production default to false, so this is no longer necessary. I’ll revert it.
|
Thanks for the review, @dimas-b ! |
New tables and views created without an explicit location now get a unique, unpredictable location: defaultWarehouseLocation appends a random UUID, controlled by the new DEFAULT_TABLE_LOCATION_USE_UUID feature flag (on by default), so no two tables share a path prefix. Here is an example.
Before:
After (default, DEFAULT_TABLE_LOCATION_USE_UUID=true):
Caller-specified locations are now rejected by default, controlled by the new ALLOW_CLIENT_SPECIFIED_TABLE_LOCATION flag (off by default). I'm OK if people think we should set it to
onby default givenoffis another behavior change. This covers the top-levellocationfield, aSetLocationupdate, and thewrite.data.path/write.metadata.pathproperties, on both create (create-table/create-view) and update (update-table/replace-view) requests. Staged-create commits, register table/view, and federated catalogs are unaffected.Existing tables and views are untouched. To restore the previous behavior, set
polaris.config.default-table-location.use-uuid=falseandpolaris.config.allow.client-specified.table.location=true.Followup optimization:
Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)