Re:PRQL a simple, powerful, pipelined SQL replacement
by ailef on Friday December 30, 2022 @09:45AM
(#34185469)
What is the reason for trailing commas and ands/ors?
Re:PRQL a simple, powerful, pipelined SQL replacement
by thomasmg on Friday December 30, 2022 @10:24AM
(#34185820)
So that you can generate SQL more easily, and (for hand-written statements) so that you can re-order lines more easily. Many programming languages support trailing commas.
Re:PRQL a simple, powerful, pipelined SQL replacement
by zestyping on Friday December 30, 2022 @06:21PM
(#34191343)
Trailing "and"s and "or"s looks so wrong to me; it reads so strongly like a syntax error. How about Boolean functions instead, like so:
select
a,
b,
from t
where any(
all(a.x is :x, a.y is :y,),
b.x is :x,
)
This way you get the uniformity you want from trailing commas, without the syntax looking quite so weird.
Re:PRQL a simple, powerful, pipelined SQL replacement
by vbezhenar on Saturday December 31, 2022 @03:34AM
(#34194706)
That's even better.
Re:PRQL a simple, powerful, pipelined SQL replacement
by ttfkam on Sunday January 01, 2023 @12:11PM
(#34208195)
As an aside, avoid OR as much as possible in your WHERE clauses. Adjust your relations if necessary. ORs can really blow the planner up and slow things down. ANDs are reductive wrt indexes. ORs make multiple passes on the indexes necessary.
It's not always possible to avoid, and it makes perfect sense sometimes, but it'd be better if folks didn't lean into OR so much.
1. Support trailing commas.
2. Add operator `is` which works like `==` but for nulls it returns `true`. Could also remove automatic type casting, I'd be happy about that, never liked it.
3. Support trailing `or`-s and `and`-s.
So query could look like