youngyjd closed pull request #6478: [bugfix] show results in query history
URL: https://github.com/apache/incubator-superset/pull/6478
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
b/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
index 7953d636d9..130c9c61bf 100644
--- a/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
+++ b/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
@@ -68,7 +68,7 @@ describe('async actions', () => {
it('calls querySuccess on fetch success', () =>
makeRequest().then(() => {
expect(dispatch.callCount).toBe(2);
- expect(dispatch.getCall(1).args[0].type).toBe(actions.QUERY_SUCCESS);
+
expect(dispatch.getCall(1).args[0].type).toBe(actions.RENDER_QUERY_RESULTS);
}));
it('calls queryFailed on fetch error', () => {
@@ -117,7 +117,7 @@ describe('async actions', () => {
return makeRequest().then(() => {
expect(dispatch.callCount).toBe(2);
expect(dispatch.getCall(0).args[0].type).toBe(actions.START_QUERY);
- expect(dispatch.getCall(1).args[0].type).toBe(actions.QUERY_SUCCESS);
+
expect(dispatch.getCall(1).args[0].type).toBe(actions.RENDER_QUERY_RESULTS);
});
});
diff --git a/superset/assets/src/SqlLab/actions/sqlLab.js
b/superset/assets/src/SqlLab/actions/sqlLab.js
index 084aaea80f..d8817354fa 100644
--- a/superset/assets/src/SqlLab/actions/sqlLab.js
+++ b/superset/assets/src/SqlLab/actions/sqlLab.js
@@ -35,13 +35,14 @@ export const QUERY_EDITOR_PERSIST_HEIGHT =
'QUERY_EDITOR_PERSIST_HEIGHT';
export const SET_DATABASES = 'SET_DATABASES';
export const SET_ACTIVE_QUERY_EDITOR = 'SET_ACTIVE_QUERY_EDITOR';
export const SET_ACTIVE_SOUTHPANE_TAB = 'SET_ACTIVE_SOUTHPANE_TAB';
+export const SET_QUERY_STATE_SUCCESS = 'SET_QUERY_STATE_SUCCESS';
export const REFRESH_QUERIES = 'REFRESH_QUERIES';
export const SET_USER_OFFLINE = 'SET_USER_OFFLINE';
export const RUN_QUERY = 'RUN_QUERY';
export const START_QUERY = 'START_QUERY';
export const STOP_QUERY = 'STOP_QUERY';
export const REQUEST_QUERY_RESULTS = 'REQUEST_QUERY_RESULTS';
-export const QUERY_SUCCESS = 'QUERY_SUCCESS';
+export const RENDER_QUERY_RESULTS = 'RENDER_QUERY_RESULTS';
export const QUERY_FAILED = 'QUERY_FAILED';
export const CLEAR_QUERY_RESULTS = 'CLEAR_QUERY_RESULTS';
export const REMOVE_DATA_PREVIEW = 'REMOVE_DATA_PREVIEW';
@@ -81,8 +82,8 @@ export function startQuery(query) {
return { type: START_QUERY, query };
}
-export function querySuccess(query, results) {
- return { type: QUERY_SUCCESS, query, results };
+export function renderQueryResults(query, results) {
+ return { type: RENDER_QUERY_RESULTS, query, results };
}
export function queryFailed(query, msg, link) {
@@ -93,6 +94,10 @@ export function stopQuery(query) {
return { type: STOP_QUERY, query };
}
+export function setQueryStateSuccess(query) {
+ return { type: SET_QUERY_STATE_SUCCESS, query };
+}
+
export function clearQueryResults(query) {
return { type: CLEAR_QUERY_RESULTS, query };
}
@@ -115,7 +120,7 @@ export function fetchQueryResults(query) {
})
.then(({ text = '{}' }) => {
const bigIntJson = JSONbig.parse(text);
- dispatch(querySuccess(query, bigIntJson));
+ dispatch(renderQueryResults(query, bigIntJson));
})
.catch(response =>
getClientErrorObject(response).then((error) => {
@@ -152,7 +157,7 @@ export function runQuery(query) {
})
.then(({ json }) => {
if (!query.runAsync) {
- dispatch(querySuccess(query, json));
+ dispatch(renderQueryResults(query, json));
}
})
.catch(response =>
diff --git a/superset/assets/src/SqlLab/components/QueryAutoRefresh.jsx
b/superset/assets/src/SqlLab/components/QueryAutoRefresh.jsx
index 295c32f8bb..1e9fe05e1b 100644
--- a/superset/assets/src/SqlLab/components/QueryAutoRefresh.jsx
+++ b/superset/assets/src/SqlLab/components/QueryAutoRefresh.jsx
@@ -26,7 +26,7 @@ class QueryAutoRefresh extends React.PureComponent {
return (
queriesLastUpdate > 0 &&
Object.values(queries).some(
- q => ['running', 'started', 'pending', 'fetching',
'rendering'].indexOf(q.state) >= 0 &&
+ q => ['running', 'started', 'pending', 'fetching'].indexOf(q.state) >=
0 &&
now - q.startDttm < MAX_QUERY_AGE_TO_POLL,
)
);
diff --git a/superset/assets/src/SqlLab/components/ResultSet.jsx
b/superset/assets/src/SqlLab/components/ResultSet.jsx
index c7c10cd586..207ec5773d 100644
--- a/superset/assets/src/SqlLab/components/ResultSet.jsx
+++ b/superset/assets/src/SqlLab/components/ResultSet.jsx
@@ -64,6 +64,14 @@ export default class ResultSet extends React.PureComponent {
this.fetchResults(nextProps.query);
}
}
+ componentDidUpdate() {
+ if (this.props.query.state === 'rendering') {
+ this.setQueryStateSuccess();
+ }
+ }
+ setQueryStateSuccess() {
+ this.props.actions.setQueryStateSuccess(this.props.query);
+ }
clearQueryResults(query) {
this.props.actions.clearQueryResults(query);
}
@@ -163,7 +171,7 @@ export default class ResultSet extends React.PureComponent {
</Button>
</Alert>
</div>);
- } else if (query.state === 'success') {
+ } else if (['rendering', 'success'].indexOf(query.state) >= 0) {
const results = query.results;
let data;
if (this.props.cache && query.cached) {
diff --git a/superset/assets/src/SqlLab/reducers/sqlLab.js
b/superset/assets/src/SqlLab/reducers/sqlLab.js
index ff881c327a..ffea695139 100644
--- a/superset/assets/src/SqlLab/reducers/sqlLab.js
+++ b/superset/assets/src/SqlLab/reducers/sqlLab.js
@@ -154,7 +154,10 @@ export default function sqlLabReducer(state = {}, action) {
[actions.REQUEST_QUERY_RESULTS]() {
return alterInObject(state, 'queries', action.query, { state: 'fetching'
});
},
- [actions.QUERY_SUCCESS]() {
+ [actions.SET_QUERY_STATE_SUCCESS]() {
+ return alterInObject(state, 'queries', action.query, { state: 'success'
});
+ },
+ [actions.RENDER_QUERY_RESULTS]() {
let rows;
if (action.results.data) {
rows = action.results.data.length;
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]