Skip to content

Commit

Permalink
feat(trino): add source application to trino backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 31, 2023
1 parent 84d38a1 commit cf5fdb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ibis/backends/trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def do_connect(
port: int = 8080,
database: str | None = None,
schema: str | None = None,
source: str | None = None,
**connect_args,
) -> None:
"""Create an Ibis client connected to a Trino database."""
Expand All @@ -85,6 +86,7 @@ def do_connect(
host=host,
port=port,
database=database,
query=dict(source="ibis" if source is None else source),
)
connect_args.setdefault("timezone", "UTC")
with warnings.catch_warnings():
Expand Down
20 changes: 20 additions & 0 deletions ibis/backends/trino/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import pytest

import ibis
from ibis.backends.trino.tests.conftest import (
TRINO_HOST,
TRINO_PASS,
TRINO_PORT,
TRINO_USER,
)


@pytest.fixture
Expand Down Expand Up @@ -56,3 +62,17 @@ def test_list_catalogs(con):

def test_list_schemas(con):
assert {"information_schema", "sf1"}.issubset(con.list_schemas(database="tpch"))


@pytest.mark.parametrize(("source", "expected"), [(None, "ibis"), ("foo", "foo")])
def test_con_source(source, expected):
con = ibis.trino.connect(
user=TRINO_USER,
host=TRINO_HOST,
port=TRINO_PORT,
password=TRINO_PASS,
database="hive",
schema="default",
source=source,
)
assert con.con.url.query["source"] == expected

0 comments on commit cf5fdb9

Please sign in to comment.