Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime syntax validation of queries in SQL lab #6707

Closed
amalakar opened this issue Jan 16, 2019 · 3 comments · Fixed by #7518
Closed

Realtime syntax validation of queries in SQL lab #6707

amalakar opened this issue Jan 16, 2019 · 3 comments · Fixed by #7518
Labels
enhancement:request Enhancement request submitted by anyone from the community sqllab Namespace | Anything related to the SQL Lab

Comments

@amalakar
Copy link
Contributor

amalakar commented Jan 16, 2019

Real time query validation in sql lab I think could be a very useful and powerful feature, it can bring in equivalent productivity modern IDEs bring to programming. I also noticed that query engine's like presto does have a very easy way to validate queries, prepending explain (TYPE VALIDATE) to a query validates the syntax of the query. Other query engine's may support similar functionalities as well. Here is some test of query validation for presto engine

Valid query

presto:default> explain (TYPE VALIDATE) select * from hive.default.test_table where ds='2019-01-01' limit 10;
 Valid
-------
 true
(1 row)

Invalid table name:

Query 20190116_163346_02068_b85df failed: line 1:39: Table hive.default.test_table_x does not exist
explain (TYPE VALIDATE) select * from hive.default.test_table_x where ds='2019-01-01' and audit_source='presto' limit 10 

Invalid column

presto:default> explain (TYPE VALIDATE) select * from hive.default.test_table_x where ds='2019-01-01' and col1='abc' limit 10;
Query 20190116_163535_02086_b85df failed: line 1:99: Column 'col1' cannot be resolved
explain (TYPE VALIDATE) select * from hive.default.test_table_x where ds='2019-01-01' and col1='abc' limit 10

More: https://prestodb.io/docs/current/sql/explain.html

Examples of such feature in other sql editors:

query-validation

@mistercrunch
Copy link
Member

EXPLAIN is very standard but somewhat costly (guessing TYPE VALIDATE is probably cheaper), triggering it onChange might be rough on the coordinator. We could wait 2-5 seconds after the last change to actually trigger the validation, depending on how much the query planner can take.

I know BigQuery's UI has that feature and it was requested internally at Lyft before.

From a Superset standpoint it should be fairly easy, we'd add a new validate_sql(sql) method in superset.db_engine_specs that would return something like boolean and an array of know errors, maybe line number + message. Then we need a new REST endpoint to serve this and maybe a database configuration setting sql_validation_interval_ms or something that is off if == 0, otherwise defines the interval at which we validate.

@kristw kristw added enhancement:request Enhancement request submitted by anyone from the community sqllab Namespace | Anything related to the SQL Lab labels Jan 17, 2019
@stale
Copy link

stale bot commented Apr 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 10, 2019
@prashantkommireddi
Copy link

very interested in this feature. does this lie on Superset's immediate roadmap?

@stale stale bot removed the inactive Inactive for >= 30 days label Apr 14, 2019
bearcage pushed a commit to bearcage/incubator-superset that referenced this issue May 6, 2019
This builds on apache#7422 to build check-as-you-type sql
query validation in Sql Lab. This closes apache#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.
xtinec pushed a commit that referenced this issue May 6, 2019
* [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
bearcage pushed a commit to bearcage/incubator-superset that referenced this issue May 15, 2019
* [WIP] Live query validation, where supported

This builds on apache#7422 to build check-as-you-type sql
query validation in Sql Lab. This closes apache#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
xtinec pushed a commit that referenced this issue May 15, 2019
* [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
bearcage pushed a commit to bearcage/incubator-superset that referenced this issue May 15, 2019
)

* [WIP] Live query validation, where supported

This builds on apache#7422 to build check-as-you-type sql
query validation in Sql Lab. This closes apache#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
xtinec pushed a commit that referenced this issue May 15, 2019
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:request Enhancement request submitted by anyone from the community sqllab Namespace | Anything related to the SQL Lab
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants