Skip to content

Commit 9538d51

Browse files
authored
fix(pyspark): avoid potentially different field names produced by SQL by using python-native APIs (#10877)
1 parent a707778 commit 9538d51

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ibis/backends/pyspark/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ def list_databases(
356356
self, *, like: str | None = None, catalog: str | None = None
357357
) -> list[str]:
358358
with self._active_catalog(catalog):
359-
databases = [
360-
db.namespace for db in self._session.sql("SHOW DATABASES").collect()
361-
]
359+
databases = [db.name for db in self._session.catalog.listDatabases()]
362360
return self._filter_with_like(databases, like)
363361

364362
def list_tables(

ibis/backends/pyspark/tests/test_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def test_catalog_db_args(con):
3939
assert con.current_database == "ibis_testing"
4040

4141

42+
def test_list_databases(con):
43+
assert "ibis_testing" in con.list_databases(catalog="spark_catalog")
44+
45+
4246
def test_create_table_no_catalog(con):
4347
t = ibis.memtable({"epoch": [1712848119, 1712848121, 1712848155]})
4448

0 commit comments

Comments
 (0)