Skip to content

Introduce reserved-properties setting; reserve "polaris." by default #1417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 9, 2025

Conversation

eric-maynard
Copy link
Contributor

@eric-maynard eric-maynard commented Apr 21, 2025

This PR reserves the prefix "polaris." for entity properties and provides a configuration to change the list of reserved prefixes. This is helpful for a few reasons:

  1. It allows the system to set real properties (i.e. setting polaris.internal.owner=eric in a metadata.json) that the user can't modify through the REST API
  2. It allows the system to inject virtual properties (e.g. polaris.virtual.load-duration-ms=1234) into an object that's being loaded, and we can avoid any potential conflict between these virtual properties and real properties
  3. It can prevent unexpected behavior changes when a user's existing conflict becomes a Polaris property. Currently Polaris properties do not follow any kind of structure (e.g. allow.overlapping.table.location) and I plan to fix this in a followup. In the future, these properties can be of a structure like polaris.config.allow.overlapping.table.location and we can allowlist the properties through the reserved-properties filter.

Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

LGTM overall with a bunch of minor comments :)

CatalogRole okCatalogRole = new CatalogRole("mycatalogrole", Map.of("foo", "bar"), 0L, 0L, 1);
try (Response response =
managementApi
.request("v1/catalogs/{cat}/catalog-roles", Map.of("cat", catalogName))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe .createCatalogRole(catalogName, okCatalogRole) (add new utility method)?

Copy link
Contributor Author

@eric-maynard eric-maynard May 8, 2025

Choose a reason for hiding this comment

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

The reason I didn't do this is that the methods in e.g. ManagementApi have assertThat(response.getStatus()).isEqualTo(CREATED.getStatusCode()) baked into them. The standard in this test and elsewhere seems to be that if you expect a different status code, you don't use a helper method.

See existing test testCreateCatalogWithInvalidName for an example.

for (var entry : updateProperties.entrySet()) {
// If a key was removed from the update, we substitute in the existing value as to not remove
// it
if (!updatePropertiesWithoutReservedProperties.containsKey(entry.getKey())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be simpler to check isReserved(entry.getKey())?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line might be a little more intuitive, but I'm not sure about simpler. We already did the check in removeReservedProperties, so we don't need to redo it here

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

throw new IllegalArgumentException(message);
} else {
LOGGER.debug(message);
isReserved = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it would be clearer to move this above line 89 and do a break here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the line, but I think we shouldn't break so that multiple logs can be emitted

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough.

Map<String, String> propertyMap =
properties.stream().collect(Collectors.toMap(k -> k, k -> ""));
Map<String, String> filteredMap = removeReservedProperties(propertyMap);
return filteredMap.keySet().stream().toList();
Copy link
Contributor

Choose a reason for hiding this comment

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

If we had an isReserved(name) method, we could simply filter the original list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good idea, but I think we'd still want to delegate to the other removeReservedProperties implementation so that we don't have to duplicate the logic to log/throw

Copy link
Contributor

Choose a reason for hiding this comment

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

good point

Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

LGTM, but I think the comment about break in the prefix loop is a good thing to have proactively.

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board May 8, 2025
@dimas-b
Copy link
Contributor

dimas-b commented May 8, 2025

Let's keep it open for another day or so in case other people have opinions on this change.

@eric-maynard eric-maynard merged commit da23e66 into apache:main May 9, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board May 9, 2025
@singhpk234
Copy link
Contributor

Awesome @eric-maynard ! I am gonna rebase the rollback compaction pr to this !

snazy added a commit to snazy/polaris that referenced this pull request May 22, 2025
* Doc: Add release guide on the website (apache#1539)

* main: Update actions/stale digest to f78de97 (apache#1547)

* main: Update dependency boto3 to v1.38.12 (apache#1548)

* main: Update postgres Docker tag to v17.5 (apache#1549)

* main: Update dependency com.adobe.testing:s3mock-testcontainers to v4.2.0 (apache#1551)

* main: Update dependency com.nimbusds:nimbus-jose-jwt to v10.3 (apache#1552)

* Interface changes for pagination (apache#1528)

* add missing apis

* more tests, fixes

* clean up drop

* autolint

* changes per review

* revert iceberg messages to comply with oss tests

* another revert

* more iceberg catalog changes

* autolint

* dependency issues

* more wiring

* continuing rebase

* remaining issues are related to task loading

* re-add tests

* debugging

* fix failing tests

* fix another test

* changes per review

* autolint

* some fixes

* stable

* updates for new persistence

* fix

* continuing work

* more reverts

* continue reverts

* more reverts

* yank tests

* autolint

* test reverts

* try to support limit without real page tokens

* autolint

* Stable

* change comment

* autolint

* remove catalog config for now

* changes per review

* more tweaks

* simplify types per review

* Stable, about to refactor more

* re-stable

* polish

* autolint

* more changes per review

* stable

* Introduce reserved-properties setting; reserve "polaris." by default (apache#1417)

* initial commit

* initial commit

* try to test

* quarkus fixes

* fix a bunch of callsites

* Start applying changes

* autolint

* chase todos

* autolint

* bugfix

* stable

* add one test

* stable with more tests

* autolint

* more tests

* autolint

* stable tests

* clean up

* oops

* stabilize on main

* autolint

* more changes per review

* Add cleanup support for partition-level statistics files when `DROP TABLE PURGE` (apache#1508)

* cleaning up partition stats

* update partition stat file extension

* update test partition stat write impl

* Implement federation to HadoopCatalog (apache#1466)

* wip

* quarkus fixes

* autolint

* hadoop impl

* autolint

* Refactors

* refactored

* autolint

* add config

* autolint

* stable

* Remove breakpoint anchor

* add line to application.properties

* yank HADOOP

* autolint

* Spark: Use builder for CreateGenericTableRequest instead of constructor for easier API spec update (apache#1546)

* main: Update docker.io/jaegertracing/all-in-one Docker tag to v1.69.0 (apache#1559)

* main: Update dependency io.opentelemetry:opentelemetry-bom to v1.50.0 (apache#1558)

* main: Update dependency software.amazon.awssdk:bom to v2.31.40 (apache#1567)

* main: Update dependency boto3 to v1.38.13 (apache#1556)

* Include DISCLAIMER in binary distributions (apache#1568)

* NoSQL: merge/rebase-fixes

* NoSQL: bump dependencies

* fix markdown

---------

Co-authored-by: JB Onofré <jbonofre@apache.org>
Co-authored-by: Mend Renovate <bot@renovateapp.com>
Co-authored-by: Eric Maynard <eric.maynard+oss@snowflake.com>
Co-authored-by: danielhumanmod <danieltu.life@gmail.com>
Co-authored-by: gh-yzou <167037035+gh-yzou@users.noreply.github.com>
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.

3 participants