Skip to content

fix(pyspark): avoid potentially different field names produced by SQL by using python-native APIs #10877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ibis/backends/pyspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@
self, *, like: str | None = None, catalog: str | None = None
) -> list[str]:
with self._active_catalog(catalog):
databases = [
db.namespace for db in self._session.sql("SHOW DATABASES").collect()
]
databases = [db.name for db in self._session.catalog.listDatabases()]

Check warning on line 359 in ibis/backends/pyspark/__init__.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/pyspark/__init__.py#L359

Added line #L359 was not covered by tests
return self._filter_with_like(databases, like)

def list_tables(
Expand Down
4 changes: 4 additions & 0 deletions ibis/backends/pyspark/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
assert con.current_database == "ibis_testing"


def test_list_databases(con):
assert "ibis_testing" in con.list_databases(catalog="spark_catalog")

Check warning on line 43 in ibis/backends/pyspark/tests/test_client.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/pyspark/tests/test_client.py#L42-L43

Added lines #L42 - L43 were not covered by tests


def test_create_table_no_catalog(con):
t = ibis.memtable({"epoch": [1712848119, 1712848121, 1712848155]})

Expand Down