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

Support SET SESSION AUTHORIZATION on trino-python-client #349

Merged

Conversation

baohe-zhang
Copy link
Contributor

@baohe-zhang baohe-zhang commented Mar 18, 2023

Description

This PR is to support SET SESSION AUTHORIZATION user and RESET SESSION AUTHORIZATION sql commands on the python client. Those 2 sql commands are supported on the server side from this PR trinodb/trino#16067

Related to issue trinodb/trino#2512

Tested locally with the script:

from trino.dbapi import connect

conn = connect(
    host="localhost",
    port=8080,
    user="baozhang",
    catalog="tpch"
)
cur = conn.cursor()

cur.execute("SELECT COUNT(*) FROM tpch.sf1.orders")
rows = cur.fetchall()
assert rows[0][0] == 1500000

cur.execute("SELECT CURRENT_USER")
rows = cur.fetchall()
assert rows[0][0] == 'baozhang'

cur.execute("SET SESSION AUTHORIZATION 'prestodv'")
cur.execute("SELECT CURRENT_USER")
rows = cur.fetchall()
assert rows[0][0] == 'prestodv'

cur.execute("RESET SESSION AUTHORIZATION")
cur.execute("SELECT CURRENT_USER")
rows = cur.fetchall()
assert rows[0][0] == 'baozhang'

Non-technical explanation

Release notes

( ) This is not user-visible or docs only and no release notes are required.
(x) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

@cla-bot
Copy link

cla-bot bot commented Mar 18, 2023

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Baohe Zhang.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

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.

@baohe-zhang Thanks for the PR.

Once the change is available on the server please add some functional tests as well and we can then merge this PR.

@hashhar
Copy link
Member

hashhar commented Aug 31, 2023

@baohe-zhang Seems the change was merged in server. Once Trino 426 with this change is available please add some tests.

@hashhar
Copy link
Member

hashhar commented Sep 15, 2023

@baohe-zhang The server side change was merged. Can you add some tests here and we can merge this.

@hashhar hashhar force-pushed the support_set_session_authorization_python branch from 000e303 to faf00b6 Compare June 24, 2024 05:41
@hashhar
Copy link
Member

hashhar commented Jun 24, 2024

Rebased to resolve conflicts.

We agreed to not add integration tests since it requires configuring a Trino catalog with a connector that supports impersonation and would require some mechanism to build such customized docker image for tests.

Verifying that the header is propagated correctly in the requests should be sufficient on the client and testing whether the header behaves is already tested on the server.

@hashhar hashhar force-pushed the support_set_session_authorization_python branch from faf00b6 to 5f75870 Compare June 24, 2024 05:46
@hashhar hashhar merged commit 169226e into trinodb:master Jun 24, 2024
12 checks passed
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.

2 participants