-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
[explore view] fix long query issue from Run in SQL LAB Button #9345
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2703,7 +2703,7 @@ def profile(self, username): | |
) | ||
|
||
@staticmethod | ||
def _get_sqllab_payload(user_id: int) -> Dict[str, Any]: | ||
def _get_sqllab_tabs(user_id: int) -> Dict[str, Any]: | ||
# send list of tab state ids | ||
tabs_state = ( | ||
db.session.query(TabState.id, TabState.label) | ||
|
@@ -2743,19 +2743,30 @@ def _get_sqllab_payload(user_id: int) -> Dict[str, Any]: | |
} | ||
|
||
return { | ||
"defaultDbId": config["SQLLAB_DEFAULT_DBID"], | ||
"common": common_bootstrap_payload(), | ||
"tab_state_ids": tabs_state, | ||
"active_tab": active_tab.to_dict() if active_tab else None, | ||
"databases": databases, | ||
"queries": queries, | ||
} | ||
|
||
@has_access | ||
@expose("/sqllab") | ||
@expose("/sqllab", methods=["GET", "POST"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is to make /sqllab page accept POST There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The request is accepted but the post data is not used, hence the SQL query is actually not pre-populated in the SQL editor as it is now. Previously the search query is acquired at the client side: cefedf6#diff-2782bdc5cd0627eef4679c85a44d4ac1L102 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i merged your code snippet. now it works. thanks! |
||
def sqllab(self): | ||
"""SQL Editor""" | ||
payload = self._get_sqllab_payload(g.user.get_id()) | ||
payload = { | ||
"defaultDbId": config["SQLLAB_DEFAULT_DBID"], | ||
"common": common_bootstrap_payload(), | ||
} | ||
|
||
tabs_data = self._get_sqllab_tabs(g.user.get_id()) | ||
payload.update(tabs_data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can rewrite with dict unpacking: payload = {
"defaultDbId": config["SQLLAB_DEFAULT_DBID"],
"common": common_bootstrap_payload(),
**self._get_sqllab_tabs(g.user.get_id())
} |
||
|
||
form_data = request.form.get("form_data") | ||
if form_data: | ||
try: | ||
payload["requested_query"] = json.loads(form_data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i prefer call it |
||
except json.JSONDecodeError: | ||
pass | ||
bootstrap_data = json.dumps( | ||
payload, default=utils.pessimistic_json_iso_dttm_ser | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename
exploreForm
to something more generic. E.g.,hiddenForm
.