Skip to content

Commit

Permalink
fix(snowflake): include views when listing tables for backwards compa…
Browse files Browse the repository at this point in the history
…tibility
  • Loading branch information
cpcloud committed Oct 22, 2023
1 parent f5bb555 commit 094881b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ def list_tables(
types of `table`.
:::
"""
query = "SHOW TABLES"

if database is not None and schema is None:
util.warn_deprecated(
Expand All @@ -517,13 +516,22 @@ def list_tables(
sg.table(schema, db=database, quoted=True).sql(dialect=self.name)
or None
)

tables_query = "SHOW TABLES"
views_query = "SHOW VIEWS"

if database is not None:
query += f" IN {database}"
tables_query += f" IN {database}"
views_query += f" IN {database}"

with self.begin() as con:
tables = [row["name"] for row in con.exec_driver_sql(query).mappings()]
# TODO: considering doing this with a single query using information_schema
tables = [
row["name"] for row in con.exec_driver_sql(tables_query).mappings()
]
views = [row["name"] for row in con.exec_driver_sql(views_query).mappings()]

return self._filter_with_like(tables, like=like)
return self._filter_with_like(tables + views, like=like)

def _register_in_memory_table(self, op: ops.InMemoryTable) -> None:
import pyarrow.parquet as pq
Expand Down

0 comments on commit 094881b

Please sign in to comment.