From e0f54c93d7d851239a1f7964d16fcd18285a2ee0 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 3 Sep 2024 08:12:10 -0400 Subject: [PATCH] feat(trino): wrap `auth` strings with `BasicAuthentication` (#9960) --- ibis/backends/trino/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ibis/backends/trino/__init__.py b/ibis/backends/trino/__init__.py index e694f042fae1..da57d5cfa6c6 100644 --- a/ibis/backends/trino/__init__.py +++ b/ibis/backends/trino/__init__.py @@ -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 @@ -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, @@ -321,7 +332,7 @@ def do_connect( schema=schema, source=source or "ibis", timezone=timezone, - auth=auth or password, + auth=auth, **kwargs, )