- 
                Notifications
    You must be signed in to change notification settings 
- Fork 748
add parse function in /validate endpoint for SQL #6517
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
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub. 
 | 
| Breaking changes detected in the OpenAPI specification! | 
    
      
        2 similar comments
      
    
  
    | Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
    
      
        1 similar comment
      
    
  
    | Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
## 📝 Summary <!-- Provide a concise summary of what this pull request is addressing. If this PR fixes any issues, list them here by number (e.g., Fixes #123). --> Uses get_connection_for_sql (so we catch DBAPI and other queryEngines). Adds kernel tests for this codepath. Update parse tests introduced by Myles, but note that they aren't correct (many queries do not raise ParseErrors by duckdb) ## 🔍 Description of Changes <!-- Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> ## 📋 Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [x] I have added tests for the changes made. - [x] I have run the code and verified that it works as expected.
728ced0    to
    f3973aa      
    Compare
  
    | Breaking changes detected in the OpenAPI specification! | 
| Breaking changes detected in the OpenAPI specification! | 
| I removed the  | 
📝 Summary
Adds a parse function in
/validateendpoint that currently supports duckdb so we get better lint errors when writing SQL cells./validate runs
SELECT JSON_SERIALIZE_SQLin duckdb, which returns a structured error response (for a majority of queries)https://duckdb.org/docs/stable/data/json/sql_to_and_from_json.html.
We then convert the json response to linter error format
A custom sql parser is created to use this new endpoint, everytime the parser runs
validateSqlfor DuckDB, it will call this endpoint instead of using NodeSqlParser default parsing.This PR also disables the
EXPLAINmode because they use the same endpoint and so there is a perf hit when called twice. We can optimize the endpoint.Endpoint design:
/sql/validateThere are 2 possible paths:
EXPLAIN {query}. Surfaces both syntax and catalog errors (invalid table_name etc.) but is not structured.When onlyParse is true, we just run the parse function, which is the aim of this PR. In the future, we want to optimize so that we can query once and get the complete response back.
🔍 Description of Changes
📋 Checklist