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

fix: Add X-Trino-Extra-Credential header and remove user override #3246

Merged
merged 2 commits into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ def __init__(
catalog: Optional[str] = None,
auth: Optional[Any] = None,
http_scheme: Optional[str] = None,
source: Optional[str] = None,
extra_credential: Optional[str] = None,
):
self.host = host or os.getenv("TRINO_HOST")
self.port = port or os.getenv("TRINO_PORT")
self.user = user or os.getenv("TRINO_USER")
self.catalog = catalog or os.getenv("TRINO_CATALOG")
self.auth = auth or os.getenv("TRINO_AUTH")
self.http_scheme = http_scheme or os.getenv("TRINO_HTTP_SCHEME")
self.source = source or os.getenv("TRINO_SOURCE")
self.extra_credential = extra_credential or os.getenv("TRINO_EXTRA_CREDENTIAL")
self._cursor: Optional[Cursor] = None

if self.host is None:
Expand All @@ -56,13 +60,16 @@ def __init__(

def _get_cursor(self) -> Cursor:
if self._cursor is None:
headers = {trino.constants.HEADER_EXTRA_CREDENTIAL: self.extra_credential} if self.extra_credential else {}
self._cursor = trino.dbapi.connect(
host=self.host,
port=self.port,
user=self.user,
catalog=self.catalog,
auth=self.auth,
http_scheme=self.http_scheme,
source=self.source,
http_headers=headers,
).cursor()

return self._cursor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def get_table_column_names_and_types(
self, config: RepoConfig
) -> Iterable[Tuple[str, str]]:
client = Trino(
user="user",
catalog=config.offline_store.catalog,
host=config.offline_store.host,
port=config.offline_store.port,
Expand Down