3 ms·
I was kind of assuming you had those things for a YAML based frontend, and just wanted to implement SQL support. I can see that if your YAML solution doesn’t h
by t8sr 3y ago
I was kind of assuming you had those things for a YAML based frontend, and just wanted to implement SQL support.
I can see that if your YAML solution doesn’t have a way to express GROUP BY, so the backend doesn’t support it, then of course that’ll be extra work, but then that’s IMO a different feature.
SQL itself is a tiny language - a parser that transforms it into your YAML based AST really would be pretty small. Here’s the one I made many years ago: https://github.com/google/dotty/blob/master/efilter/parsers/dottysql/parser.py https://github.com/google/dotty/blob/master/efilter/parsers/...
It’s not the best quality code, and it doesn’t implement SQL92, but we did run it in production.
- frognumber 3y agoMy current JSON-based system doesn't implement full SQL semantics. We definitely don't have (or actually need) GROUP BY. Doing full SQL would require ASTs, a query optimizer, and similar. Right now, it's SQL-like, but the implementation is really quite dumb. What I actually want is the whole dotty / efilter system, only with things like documentation. We really do care about performance, though. From your code, this would not work: api.apply("SELECT name FROM users WHERE age > 10", vars={"users": ({"age": 10, "name": "Bob"}, {"age": 20, "name": "Alice"}, {"age": 30, "name": "Eve"})) It would really need to be: query = api.compile("SELECT name FROM users WHERE age > 10") query(vars={"users": ({"age": 10, "name": "Bob"}, {"age": 20, "name": "Alice"}, {"age": 30, "name": "Eve"}))) Or more likely, vars would be a closure which would allow it to interact with the proper data stores. As a footnote, that looks like a really nice project. I wish it were supported, maintained, and finished.