diff --git a/ibis/backends/trino/__init__.py b/ibis/backends/trino/__init__.py index 9856e65fb5ec..1c6132edf728 100644 --- a/ibis/backends/trino/__init__.py +++ b/ibis/backends/trino/__init__.py @@ -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: @@ -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: