-
Notifications
You must be signed in to change notification settings - Fork 246
Policy Store: Add PolicyEntity and PolicyTypes #1133
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left minor comments! Thanks @HonahX for the PR.
|
||
@JsonIgnore | ||
public int getPolicyTypeCode() { | ||
String policyTypeCode = getPropertiesAsMap().get(POLICY_TYPE_CODE_KEY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need policy type to be a top-level field instead of hidden in property map in the future, but it's fine now.
import jakarta.annotation.Nullable; | ||
|
||
/* Represents all predefined policy types in Polaris */ | ||
public enum PredefinedPolicyType implements PolicyType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: a name like SystemPolicyTypes
? Just wanna brainstorming a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "Predefined Policy" is widely used throughout our design doc, so I still lean slightly toward keeping it. However, I’ll update it to the plural form.
polaris-core/src/main/java/org/apache/polaris/core/policy/PolicyEntity.java
Outdated
Show resolved
Hide resolved
As discussed in the sync meeting, if possible, please hold this PR until a NoSQL peristence impl. is available (hopefully soon). |
Hi @dimas-b, do you mean hold #1104 which includes the new Persistence Table, interface and impl? For that, I marked #1104 as draft to allow some time for ongoing refactoring and new impl. For this one, the PolicyEntity will be persisted just like other existing entities. So I think it should not be related to any changes in persistence refactoring or new persistence impl and we can proceed this in parallel with ongoing persistence layer work. Will NoSQL persistence impl introduce any changes that affect the current persistence model for Entitites? |
Current NoSQL POC using typeCode (#1112), so adding new types will cause some interference, hence my request to hold this PR as well. |
I think it’s unreasonable to hold multiple PRs due to one persistence implementation. The NoSQL implementation isn’t the only ongoing persistence change—@singhpk234 and I are actively working on the Postgres implementation as well. Given that multiple efforts are running in parallel, we shouldn’t allow one refactor to block overall development. |
@flyrain I agee. However, I'm a bit surprised @singhpk234 and you are working on PostgreSQL backend while the "new" API are not yet finalize. @dennishuo and @dimas-b are still working on it. I just want to avoid dual effort. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test coverage is not good enough, because I could imagine errors in the Iceberg catalog implementations as soon as there's some policy in there. Also the interaction of these new types via the entity manager is untested.
Generally, I think it's better to see the whole Policy thing working in a feature branch, which can be a PR in draft state, instead of pushing small bits of rather unused code.
Hi @snazy, thanks for the feedback!
Could you clarify this concern? The Policy implementation is independent of the Iceberg catalog. It has its own service interface/implementation, handler, and a PolicyCatalog within service-common, all separate from Iceberg. (I realize part of the design doc is outdated—I'll update that section.)
I can add more tests in
I do have a draft PR #1104 that includes all necessary Polaris-core changes for the policy store, including basic classes and the PolicyMappingRecord persistence interfaces/implementations. I can publish a larger draft PR that combines core changes with the service implementation for reference. That said, I’d still recommend reviewing and merging smaller pieces incrementally—this makes it easier for everyone to review and avoids one massive PR that’s harder to manage. Let me know what you think! |
polaris-core/src/main/java/org/apache/polaris/core/policy/PolicyEntity.java
Outdated
Show resolved
Hide resolved
|
||
/* Represents all predefined policy types in Polaris */ | ||
public enum PredefinedPolicyTypes implements PolicyType { | ||
DATA_COMPACTION(0, "system.data-compaction", true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[doubt] I might be late to this, but why system
prefix ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prefix is to make it consistent with the path of the content schema of these policies, introduced in #969.
* either predefined or custom (user-defined). | ||
* | ||
* <p>A policy type can be either inheritable or non-inheritable. Inheritable policies are passed | ||
* down to lower-level entities (e.g., from a namespace to a table). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[doubt] may be a naive question, what stops these policies to inherited from namespace -> view ?
As we don't wanna run stuff for views >
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we don't wanna run stuff for views >
Good question, I think that's a valid concern. Currently, our engine determines how policies are enforced, and the TMS service is focused solely on tables. That said, if we later find it necessary to restrict inheritance, we can extend the PolicyType to provide the functionality to limit the valid target types.
cc @flyrain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, our engine determines how policies are enforced, and the TMS service is focused solely on tables
Thats true for enforcing part, but polaris here is acting as a policy store, which should make sure if such inheritence if they are un-intentional are blocked. So a call to get a TMS policy on view should return nothing.
That being said it fine if we want address this later, considering presently the caller just wants TMS on tables and never on a view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well, thanks @HonahX !
61c0059
to
444fd1b
Compare
The comment is resolved by the comment and #1133 (comment) and new unit test cases added in the new commits.
This PR introduces basic classes for supporting Policy Store in Polaris, as discussed in #1059.
This will be the first step to unblock all other Policy PRs and discussions
cc: @flyrain