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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

baohe-zhang
Copy link

@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@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@baohe-zhang baohe-zhang force-pushed the support_set_session_authorization_python branch from fe284f3 to 5e34051 Compare March 18, 2023 00:05
@cla-bot cla-bot bot added the cla-signed label Mar 18, 2023
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.

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.

None yet

2 participants