Semantic Validation #23
archiewood
started this conversation in
Ideas
Replies: 1 comment
-
|
There was extensive work regarding this in version |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
related: #6 #19
Motivation
We (evidence.dev) use Clickhouse as our query engine. Users write SQL in the browser (or compose components that write SQL), and we send queries to clickhouse. We provide errors to users if their queries are invalid.
At the moment, this requires a round trip to Clickhouse for every validation call. This puts a lot of load on Clickhouse. We'd like to intercept "definitely invalid" queries before they get sent. We can tolerate false negatives as we can fall back to clickhouse for validation.
This library would already be quite useful, but would be about 100% better if it was able to cover more error classes
Proposal: Add support for semantic validation in the core rust library
This is more a discussion than a specific issue. I've been looking into various of the open source SQL dialects and how they think about validation.
Broadly speaking, SQL validation can be divided into two types:
From the readme it seems like both are a goal of this project.
Currently, this library's validation focusses on syntax validation.
It does do some semantic validation, eg in validateWithSchema() in the typescript bindings, but as far as i can tell all the validation happens in the ts package rather than in the main rust crate.
To do semantic validation, information about the schema is essential.
Implementation
This could be added incrementally per dialect, and also need not cover all the above types of validation. eg easier to validate table and column existance, harder to validate that two expressions have types that can be compared
This would require:
select * from system.functionsorfrom duckdb_functions();etc.My sense is that it would be very hard / impossible to get to 100%, but fairly easy to get to a high percent coverage.
Beta Was this translation helpful? Give feedback.
All reactions