Skip to content

Commit

Permalink
fix(sql lab): display the 'View Results' button consistently in the h…
Browse files Browse the repository at this point in the history
…istory tab on sync mode (#19362)

* fix(sql lab): display the 'View Results' button in the history tab when running sync queries

* pr comment
  • Loading branch information
diegomedina248 committed Apr 13, 2022
1 parent c8304a2 commit 6d5d03e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions superset-frontend/src/SqlLab/components/ResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,16 @@ export default class ResultSet extends React.PureComponent<
this.clearQueryResults(nextProps.query),
);
}

// Only fetch results if the result key change
// If we didn't have a result key before, then the results are loaded elsewhere
// so we can skip it, unless the query id changed, in that case we should
// refetch regardless.
if (
nextProps.query.resultsKey &&
nextProps.query.resultsKey !== this.props.query.resultsKey
(this.props.query.resultsKey &&
nextProps.query.resultsKey &&
nextProps.query.resultsKey !== this.props.query.resultsKey) ||
(nextProps.query.id !== this.props.query.id && nextProps.query.resultsKey)
) {
this.fetchResults(nextProps.query);
}
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ export default function sqlLabReducer(state = {}, action) {
if (action.query.state === 'stopped') {
return state;
}

const alts = {
endDttm: now(),
resultsKey: action?.results?.query?.resultsKey,
progress: 100,
results: action.results,
rows: action?.results?.query?.rows || 0,
Expand Down
2 changes: 2 additions & 0 deletions superset/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ def execute_sql_statements( # pylint: disable=too-many-arguments, too-many-loca

if store_results and results_backend:
key = str(uuid.uuid4())
payload["query"]["resultsKey"] = key

logger.info(
"Query %s: Storing results in results backend, key: %s", str(query_id), key
)
Expand Down

0 comments on commit 6d5d03e

Please sign in to comment.