diff --git a/superset/assets/javascripts/SqlLab/components/ResultSet.jsx b/superset/assets/javascripts/SqlLab/components/ResultSet.jsx index f306050696643..79c6d9c8c4355 100644 --- a/superset/assets/javascripts/SqlLab/components/ResultSet.jsx +++ b/superset/assets/javascripts/SqlLab/components/ResultSet.jsx @@ -35,7 +35,7 @@ export default class ResultSet extends React.PureComponent { this.state = { searchText: '', showModal: false, - data: [], + data: null, height: props.search ? props.height - RESULT_SET_CONTROLS_HEIGHT : props.height, }; } @@ -146,44 +146,12 @@ export default class ResultSet extends React.PureComponent { const query = this.props.query; let sql; - if (query.state === 'stopped') { - return Query was stopped; - } - if (this.props.showSql) { sql = ; } - if (['running', 'pending', 'fetching'].indexOf(query.state) > -1) { - let progressBar; - let trackingUrl; - if (query.progress > 0 && query.state === 'running') { - progressBar = ( - ); - } - if (query.trackingUrl) { - trackingUrl = ( - - ); - } - return ( -
- Loading... - - {progressBar} -
- {trackingUrl} -
-
- ); + + if (query.state === 'stopped') { + return Query was stopped; } else if (query.state === 'failed') { return {query.errorMessage}; } else if (query.state === 'success' && query.ctas) { @@ -206,10 +174,10 @@ export default class ResultSet extends React.PureComponent { let data; if (this.props.cache && query.cached) { data = this.state.data; - } else { - data = results ? results.data : []; + } else if (results && results.data) { + data = results.data; } - if (results && data.length > 0) { + if (data && data.length > 0) { return (
); + } else if (data && data.length === 0) { + return The query returned no data; } } if (query.cached) { @@ -240,7 +210,36 @@ export default class ResultSet extends React.PureComponent { ); } - return The query returned no data; + let progressBar; + let trackingUrl; + if (query.progress > 0 && query.state === 'running') { + progressBar = ( + ); + } + if (query.trackingUrl) { + trackingUrl = ( + + ); + } + return ( +
+ Loading... + + {progressBar} +
+ {trackingUrl} +
+
+ ); } } ResultSet.propTypes = propTypes;