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(Presto): catch DatabaseError when testing Presto views #25559

Merged
merged 4 commits into from
Oct 11, 2023
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
6 changes: 3 additions & 3 deletions superset/db_engine_specs/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,11 +1268,11 @@ def get_create_view(
sql = f"SHOW CREATE VIEW {schema}.{table}"
try:
cls.execute(cursor, sql)
rows = cls.fetch_data(cursor, 1)

return rows[0][0]
except DatabaseError: # not a VIEW
return None
rows = cls.fetch_data(cursor, 1)

return rows[0][0]

@classmethod
def get_tracking_url(cls, cursor: Cursor) -> str | None:
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/db_engine_specs/presto_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,11 @@ def test_get_create_view_exception(self):
def test_get_create_view_database_error(self):
from pyhive.exc import DatabaseError

mock_execute = mock.MagicMock(side_effect=DatabaseError())
mock_execute = mock.MagicMock()
mock_fetch_data = mock.MagicMock(side_effect=DatabaseError())
database = mock.MagicMock()
database.get_raw_connection().__enter__().cursor().execute = mock_execute
mock_execute.fetch_data = mock_fetch_data
schema = "schema"
table = "table"
result = PrestoEngineSpec.get_create_view(database, schema=schema, table=table)
Expand Down
Loading