mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
fix(sqllab): reinstate "Force trino client async execution" (#25680)
This commit is contained in:
@@ -352,7 +352,7 @@ def test_handle_cursor_early_cancel(
|
||||
query_id = "myQueryId"
|
||||
|
||||
cursor_mock = engine_mock.return_value.__enter__.return_value
|
||||
cursor_mock.stats = {"queryId": query_id}
|
||||
cursor_mock.query_id = query_id
|
||||
session_mock = mocker.MagicMock()
|
||||
|
||||
query = Query()
|
||||
@@ -366,3 +366,32 @@ def test_handle_cursor_early_cancel(
|
||||
assert cancel_query_mock.call_args[1]["cancel_query_id"] == query_id
|
||||
else:
|
||||
assert cancel_query_mock.call_args is None
|
||||
|
||||
|
||||
def test_execute_with_cursor_in_parallel(mocker: MockerFixture):
|
||||
"""Test that `execute_with_cursor` fetches query ID from the cursor"""
|
||||
from superset.db_engine_specs.trino import TrinoEngineSpec
|
||||
|
||||
query_id = "myQueryId"
|
||||
|
||||
mock_cursor = mocker.MagicMock()
|
||||
mock_cursor.query_id = None
|
||||
|
||||
mock_query = mocker.MagicMock()
|
||||
mock_session = mocker.MagicMock()
|
||||
|
||||
def _mock_execute(*args, **kwargs):
|
||||
mock_cursor.query_id = query_id
|
||||
|
||||
mock_cursor.execute.side_effect = _mock_execute
|
||||
|
||||
TrinoEngineSpec.execute_with_cursor(
|
||||
cursor=mock_cursor,
|
||||
sql="SELECT 1 FROM foo",
|
||||
query=mock_query,
|
||||
session=mock_session,
|
||||
)
|
||||
|
||||
mock_query.set_extra_json_key.assert_called_once_with(
|
||||
key=QUERY_CANCEL_KEY, value=query_id
|
||||
)
|
||||
|
||||
@@ -55,8 +55,8 @@ def test_execute_sql_statement(mocker: MockerFixture, app: None) -> None:
|
||||
)
|
||||
|
||||
database.apply_limit_to_sql.assert_called_with("SELECT 42 AS answer", 2, force=True)
|
||||
db_engine_spec.execute.assert_called_with(
|
||||
cursor, "SELECT 42 AS answer LIMIT 2", async_=True
|
||||
db_engine_spec.execute_with_cursor.assert_called_with(
|
||||
cursor, "SELECT 42 AS answer LIMIT 2", query, session
|
||||
)
|
||||
SupersetResultSet.assert_called_with([(42,)], cursor.description, db_engine_spec)
|
||||
|
||||
@@ -106,10 +106,8 @@ def test_execute_sql_statement_with_rls(
|
||||
101,
|
||||
force=True,
|
||||
)
|
||||
db_engine_spec.execute.assert_called_with(
|
||||
cursor,
|
||||
"SELECT * FROM sales WHERE organization_id=42 LIMIT 101",
|
||||
async_=True,
|
||||
db_engine_spec.execute_with_cursor.assert_called_with(
|
||||
cursor, "SELECT * FROM sales WHERE organization_id=42 LIMIT 101", query, session
|
||||
)
|
||||
SupersetResultSet.assert_called_with([(42,)], cursor.description, db_engine_spec)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user