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: KeyError 'sql' when opening a Trino virtual dataset #30339

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions superset/commands/sql_lab/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# pylint: disable=too-few-public-methods, too-many-arguments
from __future__ import annotations

import copy
import logging
from typing import Any, TYPE_CHECKING

Expand Down Expand Up @@ -152,8 +151,6 @@ def _run_sql_json_exec_from_scratch(self) -> SqlJsonExecutionStatus:
self._validate_access(query)
self._execution_context.set_query(query)
rendered_query = self._sql_query_render.render(self._execution_context)
validate_rendered_query = copy.copy(query)
validate_rendered_query.sql = rendered_query
self._set_query_limit_if_required(rendered_query)
self._query_dao.update(
query, {"limit": self._execution_context.query.limit}
Expand Down
2 changes: 0 additions & 2 deletions superset/sqllab/sql_json_executer.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def execute(
rendered_query: str,
log_params: dict[str, Any] | None,
) -> SqlJsonExecutionStatus:
print(">>> execute <<<")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftovers from the original PR.

query_id = execution_context.query.id
try:
data = self._get_sql_results_with_timeout(
Expand All @@ -102,7 +101,6 @@ def execute(
raise
except Exception as ex:
logger.exception("Query %i failed unexpectedly", query_id)
print(str(ex))
raise SupersetGenericDBErrorException(
utils.error_msg_from_exception(ex)
) from ex
Expand Down
4 changes: 3 additions & 1 deletion superset/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
db.session.commit() # pylint: disable=consider-using-transaction
return result
except Exception as ex:
db.session.rollback() # pylint: disable=consider-using-transaction
# An error can happen before the session becomes active
if db.session.is_active:
db.session.rollback() # pylint: disable=consider-using-transaction

if on_error:
return on_error(ex)
Expand Down
Loading