Skip to content

Commit

Permalink
fix(trino): override incorrect base sqlalchemy list_schemas impleme…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
cpcloud committed Aug 31, 2023
1 parent cfbdbf1 commit 84d38a1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ibis/backends/trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ def list_databases(self, like: str | None = None) -> list[str]:
catalogs = list(con.exec_driver_sql(query).scalars())
return self._filter_with_like(catalogs, like=like)

def list_schemas(
self, like: str | None = None, database: str | None = None
) -> list[str]:
query = "SHOW SCHEMAS"

if database is not None:
query += f" IN {self._quote(database)}"

with self.begin() as con:
results = list(con.execute(query).scalars())
return self._filter_with_like(results, like=like)
schemata = list(con.exec_driver_sql(query).scalars())
return self._filter_with_like(schemata, like)

@property
def current_schema(self) -> str:
Expand Down Expand Up @@ -108,7 +116,7 @@ def column_reflect(inspector, table, column_info):

@contextlib.contextmanager
def _prepare_metadata(self, query: str) -> Iterator[dict[str, str]]:
name = util.gen_name("ibis_trino_metadata")
name = util.gen_name("trino_metadata")
with self.begin() as con:
con.exec_driver_sql(f"PREPARE {name} FROM {query}")
try:
Expand Down

0 comments on commit 84d38a1

Please sign in to comment.