fix(Presto): catch DatabaseError when testing Presto views (#25559)
Co-authored-by: Rui Zhao <zhaorui@dropbox.com>
This commit is contained in:
parent
d0f2c5581d
commit
be3714e131
|
|
@ -1268,11 +1268,11 @@ class PrestoEngineSpec(PrestoBaseEngineSpec):
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -925,9 +925,11 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
|
|||
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
|
||||
database.get_raw_connection().__enter__().cursor().fetchall = mock_fetch_data
|
||||
schema = "schema"
|
||||
table = "table"
|
||||
result = PrestoEngineSpec.get_create_view(database, schema=schema, table=table)
|
||||
|
|
|
|||
Loading…
Reference in New Issue