mirror of
https://github.com/apache/superset.git
synced 2026-04-25 02:55:07 +00:00
* [WIP] Live query validation, where supported This builds on #7422 to build check-as-you-type sql query validation in Sql Lab. This closes #6707 too. It adds a (debounced) call to the validate_sql_json API endpoint with the querytext, and on Lyft infra is able to return feedback to the user (end to end) in $TBD seconds. At present feedback is provided only through the "annotations" mechanism build in to ACE, although I'd be open to adding full text elsewhere on the page if there's interest. * fix: Unbreak lints and tests
This commit is contained in:
committed by
Christine Chambers
parent
fda1002654
commit
156b0aaa07
@@ -157,6 +157,20 @@ class AceEditorWrapper extends React.PureComponent {
|
||||
}
|
||||
});
|
||||
}
|
||||
getAceAnnotations() {
|
||||
const validationResult = this.props.queryEditor.validationResult;
|
||||
const resultIsReady = (validationResult && validationResult.completed);
|
||||
if (resultIsReady && validationResult.errors.length > 0) {
|
||||
const errors = validationResult.errors.map(err => ({
|
||||
type: 'error',
|
||||
row: err.line_number - 1,
|
||||
column: err.start_column - 1,
|
||||
text: err.message,
|
||||
}));
|
||||
return errors;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<AceEditor
|
||||
@@ -170,6 +184,7 @@ class AceEditorWrapper extends React.PureComponent {
|
||||
editorProps={{ $blockScrolling: true }}
|
||||
enableLiveAutocompletion
|
||||
value={this.state.sql}
|
||||
annotations={this.getAceAnnotations()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user