Repository navigation
feat: KiteSQL AST and SQLite dialect - #410
Merged
Merged
Conversation
Member
Author
|
@alexskinner what do you think of this PR in terms of how it reconstructs dialects? |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (88.33%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #410 +/- ##
==========================================
+ Coverage 92.99% 93.08% +0.08%
==========================================
Files 275 282 +7
Lines 39538 39885 +347
==========================================
+ Hits 36768 37125 +357
+ Misses 2770 2760 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Nov 22, 2026
Add `kite_sql::ast`, the syntax tree the binder binds. A `SqlDialect` now parses SQL text into it with `parse`, so a dialect may use any parser; `comparison_type` and `boolean_text` stay as binding hooks. The sqlparser frontend moves to `parser::generic`: `SqlParser` parses with a sqlparser dialect and converts the statements, rejecting syntax KiteSQL does not support and resolving type names through `DataTypeMapper`. The binder no longer depends on sqlparser, so the crate builds without the `parser` feature.
SqliteDialect parses SQL with SQLite's own grammar (sqlite3-parser) and lowers it into KiteSQL's AST, behind the sqlite-parser feature. SQLite syntax KiteSQL does not support is rejected.
Contributor
|
Sorry for the slow reply, I missed this before it merged. I like the direction a lot.
One small thing: #408 and #409 each add a flag to the parser's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SqlDialectA dialect now owns parsing. It turns SQL text into KiteSQL statements with any parser it likes:
Breaking changes compared with
main:parser_dialect,rewrite,map_data_typeandmap_column_typeare removed and replaced byparse.kite_sql::parser::generic::SqlParser::new(&MyParserDialect).parse(sql), then rewrites the returnedast::Statements.DataTypeMapper.DatabaseError::ParserSqlnow holds aString, so it no longer depends on sqlparser types.Built-in dialects
GenericSqlDialect(default)DIALECT_GENERIC="generic"parserGenericDialectSqliteDialectDIALECT_SQLITE="sqlite"sqlite-parsersqlite3-parserGenericSqlDialect::new().with_recursion_limit(n)limits how deeply nested the SQL may be.DataBaseBuilder::parser_recursion_limit(n)is shorthand for it on the default builder.SqliteDialectcoversSELECT(CTE, set operations, window functions,VALUES),INSERT(INSERT OR REPLACEmaps to overwrite),UPDATE,DELETE,CREATE/DROPof tables, indexes and views,ALTER TABLEcolumn operations,ANALYZEandEXPLAIN.substr/trim/ltrim/rtrim,?Nparameters,[..]quoting and postfixNOTNULL.sqlite3-parserhas no source positions, so its errors carry no span.Dynamic dialect example
DynDialectholds several dialects and forwards every hook to the current one. It starts withGenericSqlDialectregistered and current. All dialects share one catalog, so a table created under one dialect is visible under the others.You can also pick the dialect before building, for example from configuration, with
dialect.switch(name). Use.dialect(SqliteDialect)directly when the dialect is fixed at compile time.Testing
make test(631 passed),make test-async(599 passed),make clippy,make fmtcargo check --no-default-features --features sqlite-parser,rocksdb, i.e. the SQLite frontend without sqlparsersrc/dialect/mod.rs:sqlite_dialect_matches_genericruns about 20 statements in both dialects and checks that the results match, and that unsupported SQLite syntax is rejected.database_switches_between_generic_and_sqliteswitches dialects on one database.