Hey all 👋 , thanks for this amazing project, I love it.
I really want to see a non-toy-grammar that cleanly bridges Grammar of Graphics with SQL, this would be fantastic.
I started to implement your grammar on top of the Postgres bison rules and must say that I ran into a few walls.
Please don't see this as an angry list of complaints, but just as feedback from an enthusiastic database engine developer:
- The first thing that I noticed was your colon namespace in the examples. I would recommend to just use dot.qualified names here since there's no colon separators in identifier names in the major databases.
- The
VIA keyword confused me. If you develop ambitions to extend any of the major database grammars, something like an integer transform just becomes a normal expression before the alias clause, e.g. log10(foo) as x or cast(foo as integer) as x.
- If you want to use arbitrary sql expressions in clauses like
FILTER without breaking the world, you need to think about how your visualize statement can work without declaring all of your new terms as reserved sql keywords. This is seriously harmful. Right now, you cannot really just throw in a a_expr of postgres (https://github.com/postgres/postgres/blob/master/src/backend/parser/gram.y#L15837) in your filter clause because it will collide with all of your vis keywords when unreserved.
MAPPING and REMAPPING feel a bit odd, they are very close to SELECT, you just chose a different name. REMAPPING has the additional twist that it's redundant if you decide to merge VIA into MAPPING. If you had full-fledged sql result target in your mapping clause (select), remapping is just an alias after applying the cast/function call.
SETTING is very close to what several databases name USING. Plus it would imo not harm to say USING always opens paranthesis (like done in databases), to just have a cleanly separated option-value list.
I ended up implementing a slightly different version of your grammar in the end which is composing beautifully with Postgres (and does not need reserved keywords):
VISUALISE (SELECT ... FROM sales)
DRAW <geom> [AS (SELECT ... [WHERE ...] [PARTITION BY ...] [ORDER BY ...])] [USING (...)]
PLACE <geom> [USING (...)]
SCALE [<type>] <aesthetic> [FROM [...] TO [...]] [USING (...)]
FACET <cols> [BY <cols>] [USING (...)]
PROJECT [<aesthetics>] TO <type> [USING (...)]
LABEL USING (...)
Would love to hear your thoughts.
Also feel free to end this issue with a harsh comment if this left too many "let me change everything" vibes (not my intention).
Hey all 👋 , thanks for this amazing project, I love it.
I really want to see a non-toy-grammar that cleanly bridges Grammar of Graphics with SQL, this would be fantastic.
I started to implement your grammar on top of the Postgres bison rules and must say that I ran into a few walls.
Please don't see this as an angry list of complaints, but just as feedback from an enthusiastic database engine developer:
VIAkeyword confused me. If you develop ambitions to extend any of the major database grammars, something like an integer transform just becomes a normal expression before the alias clause, e.g.log10(foo) as xorcast(foo as integer) as x.FILTERwithout breaking the world, you need to think about how your visualize statement can work without declaring all of your new terms as reserved sql keywords. This is seriously harmful. Right now, you cannot really just throw in aa_exprof postgres (https://github.com/postgres/postgres/blob/master/src/backend/parser/gram.y#L15837) in your filter clause because it will collide with all of your vis keywords when unreserved.MAPPINGandREMAPPINGfeel a bit odd, they are very close to SELECT, you just chose a different name.REMAPPINGhas the additional twist that it's redundant if you decide to mergeVIAintoMAPPING. If you had full-fledged sql result target in your mapping clause (select), remapping is just an alias after applying the cast/function call.SETTINGis very close to what several databases nameUSING. Plus it would imo not harm to say USING always opens paranthesis (like done in databases), to just have a cleanly separated option-value list.I ended up implementing a slightly different version of your grammar in the end which is composing beautifully with Postgres (and does not need reserved keywords):
Would love to hear your thoughts.
Also feel free to end this issue with a harsh comment if this left too many "let me change everything" vibes (not my intention).