Skip to content
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

Accept shorthand format for system roles #341

Merged
merged 1 commit into from
Apr 10, 2023

Conversation

damian3031
Copy link
Member

Added role parameter

@cla-bot cla-bot bot added the cla-signed label Mar 2, 2023
trino/client.py Outdated
def _format_roles(self, roles):
def _format_roles(self, role, roles):
if role and roles:
raise ValueError("specify either 'role' or 'roles' parameter, but not both")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise ValueError("specify either 'role' or 'roles' parameter, but not both")
raise ValueError("Specify either 'role' or 'roles' parameter, but not both")

trino/client.py Outdated
Comment on lines 247 to 248
elif role is None and roles is None:
return {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is no-op and can be removed.

Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Why? Why not use the roles mechanism instead?

@mdesmet
Copy link
Contributor

mdesmet commented Mar 8, 2023

Why? Why not use the roles mechanism instead?

Because catalog roles are rather a legacy concept. Only hive standard SQL leverages the catalog roles. All modern access systems use a single SYSTEM role. Most users are not aware about the catalog roles concept.

Adding a single role will not confuse users but rather it will make the client more easy to use.

@damian3031
Copy link
Member Author

@hashhar @mdesmet @hovaesco I refactored PR to align with discussed approach - we could pass string with only role to roles parameter and it is transformed to system catalog role dict.

README.md Outdated
host='localhost',
port=443,
user='the-user',
roles="roleC" # equivalent to {"system": "roleC"}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would advise against a mixed case example unless we are full sure it works in all cases.

Copy link
Member

Choose a reason for hiding this comment

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

good point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to role1

@hashhar hashhar merged commit 55b1efe into trinodb:master Apr 10, 2023
@hashhar hashhar changed the title Add role parameter Accept shorthand format for system roles Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants