Skip to content

Commit

Permalink
feat(trino): wrap auth strings with BasicAuthentication (#9960)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Sep 3, 2024
1 parent a89b689 commit e0f54c9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ibis/backends/trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from functools import cached_property
from operator import itemgetter
from typing import TYPE_CHECKING, Any
from urllib.parse import unquote_plus
from urllib.parse import unquote_plus, urlparse

import sqlglot as sg
import sqlglot.expressions as sge
import trino
from trino.auth import BasicAuthentication

import ibis
import ibis.backends.sql.compilers as sc
Expand Down Expand Up @@ -309,10 +310,20 @@ def do_connect(
raise ValueError(
"Cannot specify both `auth` and `password` when connecting to Trino"
)
else:
auth = password
warnings.warn(
"The `password` parameter is deprecated and will be removed in 10.0; use `auth` instead",
FutureWarning,
)

if (
isinstance(auth, str)
and (scheme := urlparse(host).scheme)
and scheme != "http"
):
auth = BasicAuthentication(user, auth)

self.con = trino.dbapi.connect(
user=user,
host=host,
Expand All @@ -321,7 +332,7 @@ def do_connect(
schema=schema,
source=source or "ibis",
timezone=timezone,
auth=auth or password,
auth=auth,
**kwargs,
)

Expand Down

0 comments on commit e0f54c9

Please sign in to comment.