Skip to content

bug: trino backend connect incorrectly processes empty scheme #11841

@baumgold

Description

@baumgold

What happened?

Connecting to a trino database with a user/pass using http_scheme="https" does not work. I believe this is because the do_connect function does not enter the following if statement due to the walrus operator returning the scheme as an empty string which implicitly evaluates to False.

https://github.com/ibis-project/ibis/blob/11.0.0/ibis/backends/trino/__init__.py#L301

What version of ibis are you using?

ibis-framework==11.0.0

What backend(s) are you using, if any?

trino

Relevant log output

>>> import ibis
>>> conn = ibis.trino.connect(user=<user>, auth=<pass>, host=host, database=database, http_scheme="https")
>>> table = conn.table(<table-name>, database=(<catalog>, <database>))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    table = conn.table("mavenexe_optionsignalnotification", database=("raw", "mmbus"))
  File "~/.venv/lib/python3.13/site-packages/ibis/backends/sql/__init__.py", line 85, in table
    table_schema = self.get_schema(name, catalog=catalog, database=database)
  File "~/.venv/lib/python3.13/site-packages/ibis/backends/trino/__init__.py", line 174, in get_schema
    with self._safe_raw_sql(query) as cur:
         ~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/home/linuxbrew/.linuxbrew/opt/python@3.13/lib/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "~/.venv/lib/python3.13/site-packages/ibis/backends/trino/__init__.py", line 128, in _safe_raw_sql
    cur = self.raw_sql(query)
  File "~/.venv/lib/python3.13/site-packages/ibis/backends/trino/__init__.py", line 80, in raw_sql
    cur = con.cursor()
  File "~/.venv/lib/python3.13/site-packages/trino/dbapi.py", line 299, in cursor
    request = self._create_request()
  File "~/.venv/lib/python3.13/site-packages/trino/dbapi.py", line 280, in _create_request
    return trino.client.TrinoRequest(
           ~~~~~~~~~~~~~~~~~~~~~~~~~^
        self.host,
        ^^^^^^^^^^
    ...<6 lines>...
        self.request_timeout,
        ^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "~/.venv/lib/python3.13/site-packages/trino/client.py", line 498, in __init__
    self._auth.set_http_session(self._http_session)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'set_http_session'

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior inside of ibis

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions