Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions superset/assets/javascripts/SqlLab/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ export function fetchQueryResults(query) {
success(results) {
dispatch(querySuccess(query, results));
},
error() {
dispatch(queryFailed(query, 'Failed at retrieving results from the results backend'));
error(err) {
let msg = 'Failed at retrieving results from the results backend';
if (err.responseJSON && err.responseJSON.error) {
msg = err.responseJSON.error;
}
dispatch(queryFailed(query, msg));
},
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Well } from 'react-bootstrap';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { github } from 'react-syntax-highlighter/dist/styles';
import ModalTrigger from '../../components/ModalTrigger';
Expand Down Expand Up @@ -45,11 +44,9 @@ class HighlightedSql extends React.Component {
const props = this.props;
let shownSql = props.shrink ? this.shrinkSql(props.sql) : props.sql;
return (
<Well>
<SyntaxHighlighter language="sql" style={github}>
{shownSql}
</SyntaxHighlighter>
</Well>);
<SyntaxHighlighter language="sql" style={github}>
{shownSql}
</SyntaxHighlighter>);
}
generateModal() {
const props = this.props;
Expand Down
6 changes: 4 additions & 2 deletions superset/assets/javascripts/SqlLab/components/QueryTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import moment from 'moment';
import { Table } from 'reactable';
import { Label, ProgressBar } from 'react-bootstrap';
import { Label, ProgressBar, Well } from 'react-bootstrap';
import Link from './Link';
import VisualizeModal from './VisualizeModal';
import ResultSet from './ResultSet';
Expand Down Expand Up @@ -107,7 +107,9 @@ class QueryTable extends React.PureComponent {
</div>
);
q.sql = (
<HighlightedSql sql={q.sql} rawSql={q.executedSql} shrink maxWidth={60} />
<Well>
<HighlightedSql sql={q.sql} rawSql={q.executedSql} shrink maxWidth={60} />
</Well>
);
if (q.resultsKey) {
q.output = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class ResultSet extends React.PureComponent {
</Button>
);
}
return (<Alert bsStyle="warning">The query returned no data</Alert>);
return <Alert bsStyle="warning">The query returned no data</Alert>;
}
}
ResultSet.propTypes = propTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ describe('HighlightedSql', () => {
it('renders two SyntaxHighlighter in modal', () => {
const wrapper = mount(
<HighlightedSql sql={sql} rawSql="SELECT * FORM foo" shrink maxWidth={5} />);
const well = wrapper.find('.well');
expect(well).to.have.length(1);
well.simulate('click');
const pre = wrapper.find('pre');
expect(pre).to.have.length(1);
pre.simulate('click');
const modalBody = mount(wrapper.state().modalBody);
expect(modalBody.find(SyntaxHighlighter)).to.have.length(2);
});
Expand Down
5 changes: 4 additions & 1 deletion superset/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def handle_error(msg):
session.commit()
raise Exception(query.error_message)

if store_results and not results_backend:
handle_error("Results backend isn't configured.")

# Limit enforced only for retrieving the data, not for the CTA queries.
superset_query = sql_parse.SupersetQuery(executed_sql)
if not superset_query.is_select() and not database.allow_dml:
Expand Down Expand Up @@ -169,7 +172,7 @@ def handle_error(msg):
payload['query'] = query.to_dict()
payload = json.dumps(payload, default=utils.json_iso_dttm_ser)

if store_results and results_backend:
if store_results:
key = '{}'.format(uuid.uuid4())
logging.info("Storing results in results backend, key: {}".format(key))
results_backend.set(key, zlib.compress(payload))
Expand Down
7 changes: 5 additions & 2 deletions superset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ def warm_up_cache(self):
models.SqlaTable.table_name == table_name)
).first()
if not table:
json_error_response(__(
return json_error_response(__(
"Table %(t)s wasn't found in the database %(d)s",
t=table_name, s=db_name), status=404)
slices = session.query(models.Slice).filter_by(
Expand Down Expand Up @@ -2326,6 +2326,9 @@ def cached_key(self, key):
@log_this
def results(self, key):
"""Serves a key off of the results backend"""
if not results_backend:
return json_error_response("Results backend isn't configured")

blob = results_backend.get(key)
if blob:
json_payload = zlib.decompress(blob)
Expand All @@ -2335,7 +2338,7 @@ def results(self, key):
mydb = session.query(models.Database).filter_by(id=db_id).one()

if not self.database_access(mydb):
json_error_response(
return json_error_response(
get_database_access_error_msg(mydb.database_name))

return Response(
Expand Down