Comment by Ericson2314
1 year ago
We should really standardize a core language for SQL. Rust has MIR, Clang is making a CIR for C/C++. Once we have that, we'll be able to to communicate much better.
Right now, it's everyone faffing around with different mental models and ugly single pass compilers (my understanding is that parsing-->query planning is not nearly as well-separated in most DBs as parsing-->optomize-->codegen in most compilers).
> We should really standardize a core language for SQL
Do you mean something other than ISO/IEC 9075:2023 (the 9th edition of the SQL standard)?
It costs 194 CHF to read. There is room for improvement.
A core language is a minimal AST without surface syntax (and thus no bikeshedding of that) that distills the surface language to its essence.
SQL is basically the list monad, with various quotients / refinements:
- Sometimes the order doesn't matter - Sometimes there are functional dependencies - Sometimes one knows the length of the list in question is 1 (foreign key constraints)
ANSI SQL is very much a thing, and you should strive to keep your queries as close as possible to standard SQL as your database engine allows, if you want those queries to be portable to other database technology in the future.
You might enjoy https://substrait.io/