Skip to content
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

fix: Trino - handle table not found in SQLLab #26355

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion superset/db_engine_specs/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@
table_name: str,
schema_name: str | None,
) -> dict[str, Any]:
metadata = {}
metadata: dict[str, Any] = {}

if not database.has_table_by_name(table_name):
Khrol marked this conversation as resolved.
Show resolved Hide resolved
return metadata

Check warning on line 64 in superset/db_engine_specs/trino.py

View check run for this annotation

Codecov / codecov/patch

superset/db_engine_specs/trino.py#L64

Added line #L64 was not covered by tests

if indexes := database.get_indexes(table_name, schema_name):
col_names, latest_parts = cls.latest_partition(
Expand Down
16 changes: 16 additions & 0 deletions tests/integration_tests/databases/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,22 @@ def test_get_invalid_table_table_extra_metadata(self):
self.assertEqual(rv.status_code, 200)
self.assertEqual(data, {})

def test_get_invalid_table_table_extra_metadata_trino(self):
Khrol marked this conversation as resolved.
Show resolved Hide resolved
"""
Database API: Test get invalid table from table extra metadata
Trino dialect
"""
from superset.utils.database import get_or_create_db

trino_db = get_or_create_db("trino_examples", "trino://42/sd")
uri = f"api/v1/database/{trino_db.id}/table_extra/wrong_table/null/"
self.login(username="admin")
rv = self.client.get(uri)
data = json.loads(rv.data.decode("utf-8"))

self.assertEqual(rv.status_code, 200)
self.assertEqual(data, {})

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_get_select_star(self):
"""
Expand Down
Loading