Earlier quoted context omitted.
Is it too deeply entrenched to change? The number of times I have had a data.frame grouped when it wasn't supposed to be, I can count on my fingers. But the hours that I spent trying to figure it out must amount to a paycheck or two.
There's a lot of dplyr code out there, and a lot of people who know most every part of the tidyverse by heart, making breaking changes like this so far into a frameworks life would cause a lot of unnecessary work in re-coding old code as well as requring people to re-learn syntax. IMO for such a small adjustment the benefits don't outweight the costs.
PRQL – A proposal for a better SQL
281–290 of 302 posts
Re: PRQL – A proposal for a better SQL
#282Earlier quoted context omitted.
So now we have easily come up with three different ways of rewriting the query to avoid that duplication (which obviously was not a problem at all to begin with): subquery, CTE and lateral join. And there are also several more well known ways (views, custom functions, computed columns etc) so the whole premise now for even inventing a "better" language than SQL is then false? Or what am I missing. It's also weird how…
If there's multiple ways to do the same thing that's usually a BAD thing in terms of language design. Especially if some approaches are just newbie traps that experts learn to avoid, or if deciding the best method is a really subtle context-dependent decision. The ideal design is that the language encourages the one obviously "good" way to do it.
Re: PRQL – A proposal for a better SQL
#283I know this is meant to transpile to SQL and so maybe this language is the wrong place to do this, but my biggest pet peeve with SQL is the ternary logic introduced by SQL nullability. I'm begging and pleading for this wart to go away, and I would love to see some algebraic sum types (Optional/Maybe, etc.) used in their place.
Re: PRQL – A proposal for a better SQL
#284How does it handle subqueries? Especially correlated ones, where the subquery depends on the value provided by the outer query?
select
customer,
( select sum(revenue) from orders where customer=accounts.customer) as revenue,
( select count(transactionid) from orders where customer=accounts.customer) as orders
from
accounts;
That's a very simple example, but it can get VERY wordy and complex, and in my dreams I'd be able to write something like: getrevenue(cust) is select sum(revenue) from orders where customer=cust
getorders(cust) is select count(transactionid) from orders where customer=cust
select
customer,
getrevenue(customer),
getorders(customer)
from
accounts;
In a way, it's just dynamic sql without hacking strings together in unmaintainable ways.Re: PRQL – A proposal for a better SQL
#285I wrote this over the holidays, because I find SQL wonderfully elegant in its function, but really frustrating in its form. Let me know any feedback — as you can see it's still at the proposal stage. If it gains some traction I'll write an implementation.
I like the explicit pipelining idea, seems much easier to reason about. Some comments: I found the "# `|` can be used rather than newlines." a bit odd. So when using let, you're only transforming one column? I think the example would look weird with returns instead of |. Depending on your intended target, it might help adoption if you stay closer to the naming conventions of that target. If you're targeting mainstrea…
Thanks good idea, I just changed this to remove the microversions. If we use SemVer, then before `1`, we'd hold versions compatible to the 0.X, and then to the X.
Re: PRQL – A proposal for a better SQL
#286Re: PRQL – A proposal for a better SQL
#287Earlier quoted context omitted.
Isn’t it more important that the query you write with the ORM is readable than the underlying SQL it spits out? Using an ORM I can get reusable parts of a query, while writing complex joins, I’m not sure why skipping that part is good?
In my experience, a lot of very semantically reasonable and readable code end up with very penalizing SQL at the end, and it's a real challenge to then rewrite the whole into decent queries. There can be part of an app where a very bad query here and there is not important, but more often than not it creeps up in key parts of the user experience, and it becomes very hard to untangle when it becomes something importan…
Of course, I've not seen every query in existence so it's more than possible you've seen bad SQL from an ORM, but the untangling part would again fall to those skilled in the language of the ORM - unless the ORM can't produce efficient SQL in a particular case. And just as it would if the query was originally written in SQL, you'd need someone skilled in SQL to untangle that.
What would that case (where an ORM cannot produce efficient SQL) look like?
Re: PRQL – A proposal for a better SQL
#288Earlier quoted context omitted.
You've never authored a SQL query that does things like check special functions that don't exist in a table? For example: select @@version
Seems easy enough to work around with a magic table name in this hypothetical future reworked dialect of SQL? from @@special select version
from dual
select @@versionRe: PRQL – A proposal for a better SQL
#289Earlier quoted context omitted.
Thanks! I agree that integrating with the DB would allow much more from a lang. But PRQL is a bet that languages which start there (e.g Kusto) get lost because it requires changing DB, which is really hard. I worry EdgeDB may hit this issue too (but I'm really hoping it works, and they have an excellent team). As I think you're suggesting — you could imagine a language starting out as a transpiler, and then over time…
FYI I think the phrase you're looking for is "impedance mismatch" (I noticed this on the github readme too)
Re: PRQL – A proposal for a better SQL
#290Earlier quoted context omitted.
> Existence of such value introduces three value logic because expression "NULL = " is neither true nor false. Could you elaborate on that? I'm thought that in SQL `NULL=NULL` returns FALSE, much like the floats `NAN==NAN` returns false: > select if(null=null, "Yes", "No") > +----------------------------+ > | No | > +----------------------------+ What does it mean that this is neither TRUE or FALSE? I very much appre…
The value in your if is not false, it's NULL. NULL=NULL behaves exactly like NULL=42, the value is NULL. Which is what the parent was trying to explain. With Postgres: postgres=# \pset null postgres=# select null, null=null, null=42; ?column? | ?column? | ?column? ----------+----------+---------- | | (1 row)
> mysql> select 42=42,42=314,42=null,null=null;
> +-------+--------+---------+-----------+
> | 42=42 | 42=314 | 42=null | null=null |
> +-------+--------+---------+-----------+
> | 1 | 0 | NULL | NULL |
> +-------+--------+---------+-----------+
I see, thank you. This behaviour is news to me.