Skip to content

Commit

Permalink
fix(clickhouse): list temporary tables with list_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Aug 13, 2023
1 parent dc2ea25 commit 758a875
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ibis/backends/clickhouse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ def list_databases(self, like: str | None = None) -> list[str]:
def list_tables(
self, like: str | None = None, database: str | None = None
) -> list[str]:
query = "SHOW TABLES" + (f" FROM `{database}`" * (database is not None))
query = "SELECT name FROM system.tables WHERE"

if database is None:
database = "currentDatabase()"
else:
database = f"'{database}'"

query += f" database = {database} OR is_temporary"

with closing(self.raw_sql(query)) as result:
results = result.result_columns

Expand Down

0 comments on commit 758a875

Please sign in to comment.