-
Notifications
You must be signed in to change notification settings - Fork 251
Passing username for impersonation #334
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,12 +51,14 @@ class HiveServer2Connection(Connection): | |
| # HiveServer2Connection objects are associated with a TCLIService.Client | ||
| # thrift service | ||
| # it's instantiated with an alive TCLIService.Client | ||
|
|
||
| def __init__(self, service, default_db=None): | ||
| impersonate=None | ||
|
|
||
| def __init__(self, service, default_db=None, impersonate=None): | ||
| log.debug('HiveServer2Connection(service=%s, default_db=%s)', service, | ||
| default_db) | ||
| self.service = service | ||
| self.default_db = default_db | ||
| self.impersonate=impersonate | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: spaces around = to be consistent with surrounding code and PEP8 |
||
|
|
||
| def close(self): | ||
| """Close the session and the Thrift transport.""" | ||
|
|
@@ -122,6 +124,12 @@ def cursor(self, user=None, configuration=None, convert_types=True, | |
|
|
||
| log.debug('.cursor(): getting new session_handle') | ||
|
|
||
| if self.impersonate != None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be "is not None" - see https://docs.quantifiedcode.com/python-anti-patterns/readability/comparison_to_none.html |
||
| log.debug('Impersonating user %s' % self.impersonate) | ||
| configuration = { | ||
| 'impala.doas.user': self.impersonate | ||
| } | ||
|
|
||
| session = self.service.open_session(user, configuration) | ||
|
|
||
| log.debug('HiveServer2Cursor(service=%s, session_handle=%s, ' | ||
|
|
||
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.
nit: space after comma to be consistent with surrounding code and PEP8