Skip to content

Conversation

@Abyss-lord
Copy link
Contributor

What changes were proposed in this pull request?

Add Role-related Interface.

Why are the changes needed?

Fix: #9377

Does this PR introduce any user-facing change?

no

How was this patch tested?

local test.

@Abyss-lord Abyss-lord self-assigned this Dec 4, 2025
@Abyss-lord
Copy link
Contributor Author

Hi @unknowntpo @tsungchih , could you please review this PR when you have time? I’d really appreciate your feedback.

class Name(Enum):
"""The name of this privilege."""

# The privilege to create a catalog.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend to place string literals directly below the variable name to serve as documentation that can be extracted by IDEs or documentation tools. For example:

CREATE_CATALOG = (0, 1 << 0)
"""The privilege to create a catalog."""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

Returns:
str: A string representation of the AddSecurableObject instance.
"""
return f"ADDSECURABLEOBJECT {self._role_name} + {self._securable_object}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there's no + in the string representation. It turns out to be f"ADDSECURABLEOBJECT {self._role_name} {self._securable_object}". Similar issue in other XXXSecurableObject.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

Returns:
SecurableObjectImpl: The created schema SecurableObject.
"""
names = catalog.full_name().split(".")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to do split here? The behavior is different from the Java client.

MetadataObject.Type.SCHEMA, Lists.newArrayList(catalog.fullName(), schema), privileges);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

names.append(table)
return SecurableObjects.of(
MetadataObject.Type.TABLE,
names,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend to use unpacking here [*schema.full_name().split("."), table].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

@Abyss-lord
Copy link
Contributor Author

Hi @tsungchih , I've completed the code updates and would appreciate your review of the PR when you have a moment. Here's a summary of the commits:

  1. Fix some method
  2. Fix comments in privileges.py.

Copy link
Collaborator

@tsungchih tsungchih left a comment

Choose a reason for hiding this comment

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

@jerryshao LGTM. Would you like to take further review.

@jerryshao
Copy link
Contributor

@jerqi can you please help to review this, if there any missing pieces between Java and Python.

MANAGE_GRANTS = (0, 1 << 17)
"""The privilege to grant or revoke a role for the user or the group."""

CREATE_MODEL = (0, 1 << 18)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could u use REGISTER_MODEL instead of CREATE_MODEL?

CREATE_MODEL = (0, 1 << 18)
"""The privilege to create a model."""

CREATE_MODEL_VERSION = (0, 1 << 19)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could u use LINK_MODEL_VERSION instead of CREATE_MODEL_VERSION?

from gravitino.utils.precondition import Precondition


class RoleChange(ABC):
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, we didn't use RoleChange in the client side. So we could remove them.

* @param securableObject The securable object.
* @param newSecurableObject The new securable object.
* @return return a RoleChange for the update securable object.
* @return return a RoleChange for the update-securable object.
Copy link
Contributor

@jerqi jerqi Jan 8, 2026

Choose a reason for hiding this comment

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

Let us focus python part. Could u remove the modification?

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.

[Subtask] Add Role-related Interface.

4 participants