feat: Live query validation in the SQL Lab UI (#7461) (#7516) (#7518)

* [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:
Alex Berghage
2019-05-15 16:32:40 -06:00
committed by Christine Chambers
parent fda1002654
commit 156b0aaa07
7 changed files with 176 additions and 3 deletions

View File

@@ -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()}
/>
);
}