Live data from Hacker News

PRQL: Pipelined Relational Query Language

github.com

131–140 of 214 posts

Re: PRQL: Pipelined Relational Query Language

#131

This is tangential but a new query language is inevitably based in the idea that SQL is deficient in some manner (hard, not ergonomic, whatever). More interestingly, it also implies that the countless alternatives aren't good enough either. Is there an existing query language that anyone will argue is better than SQL? I have limited exposure on this, but if SQL is really not that good then I'd expect there to be a be…

What countless alternatives? I can’t think of many, and believe me, I’ve looked hard!

Re: PRQL: Pipelined Relational Query Language

#132
Syntax doesn't matter much, what in the optimizer does.

I think that right now a lot of SQL problems are baggage. Too many people are battle-taught to write hard to read, complex, deeply nested queries because older engines were bad at handling modern constructs (e.g. look, somebody got common table expession (CTE) here, let's materialize it immediately). So older style was mess of

     SELELT FROM (SELECT FROM (SELECT FROM A JOIN (SELECT ) B ON A.x=B.x))) etc
With things like improved CTEs handling by engines, it is getting easier and easier to write understandable, composable queries of structure like below. Add modern window functions that decrease another layer of complexity, things like SELECT * EXCEPT, more complex TOP statements like TOP X FOLLOWING etc and SQL will be even more simpler.

    WITH A AS (
    ),
    WITH B AS (
    ),
    WITH C AS (
       SELECT y FROM A)
    ,
    SELECT result from C
    WHERE
and in new-ish world minor improvements of different syntax shape (like that PRQL) do not really bring the benefit, from my POV. Yes, you can rewrite it in imperative looking pipeline, but optimizer can throw away some of it etc

Yes, there are things that can and should be done better in SQL, but I have yet to see compelling case for cosmetic, syntactical differences.

Re: PRQL: Pipelined Relational Query Language

#133

Hot takes: SQL is good. Great, in fact. Not just in what it's capable of doing, but in form . It has warts, yeah, but over the years I've been writing it I've realized most of them are there for a reason. To me it's more than useful, it's beautiful . It's the absolute last thing I want a replacement for.

How do we ever hope to differentiate between useful evangelism and stockholm syndrome? Either way, I'm probably learning a lot of postgresql this year.

I do really wish we had at least settled on one data format instead of having enough differences between PL data and DB data to start building ORMs.

Re: PRQL: Pipelined Relational Query Language

#134
post #102

Earlier quoted context omitted.

While there's some stuff in C#/LINQ/EF that's more verbose (left joins are often a nightmare) or not-supported, I'll always say that I prefer writing queries in EF than in SQL, at least when dealing with SQL features that are supported by EF (which is a lot of them, it's a very expressive dialect). But EF lets you start with FROM, lets you do whichever keywords you need in whichever order (instead of WHERE -> GROUP B…

The downside though is you have to grab the sql it’s generating somehow to try to optimize it, figure out what crazy cross apply madness it’s going or to figure out why it’s blowing sql servers recursion limit. I prefer to avoid linq syntax now. It’s a false economy.

Oh I agree the actual mapping framework where it converts the EF/LINQ is deeply flawed. But that's the underlying implementation.

I just mean on a linguistic level, I tremendously prefer EF/LINQ/C# to SQL.

Re: PRQL: Pipelined Relational Query Language

#135
post #125

Earlier quoted context omitted.

It is strange to hear about innovation in DuckDB - I see that they are gradually re-implementing the stuff already existing in ClickHouse. Sometimes they do a better job at promoting it.

That's probably true but the big differentiator was that DuckDB can run in your python process so there's very low fiction to adopt it. My impression of ClickHouse was that it was more like postgresql in that regard, i.e. OLAP : OLTP as ClickHouse : Postgres as DuckDB : SQLite. clickhouse-local may have closed the gap on that though. Can you embed it in Python as a library?

> Can you embed it in Python as a library?

https://github.com/chdb-io/chdb

    pip install chdb

Re: PRQL: Pipelined Relational Query Language

#136
post #7

Looks interesting but I wonder if this abstraction doesn't leak and it doesn't just become a more limited version of vanilla python + vanilla SQL.

This. If you are layering an abstraction on top of SQL to avoid the SQL, you fail that goal once something goes wrong. The reason you fail the goal is that you end up having to have skills to troubleshoot the SQL anyway. Wrong here can be: bad result, bad performance, or even just bad syntax. Unless you're ready to accept being helpless and rely on the knowledge of others... you'll want to look at what's actually hit…

What made you think the goal is to not know SQL?

Re: PRQL: Pipelined Relational Query Language

#137
post #16

Earlier quoted context omitted.

I don't get that - to me the examples are much less readable than SQL and I don't understand why I should want to use this. Like, yes, you can reorder the query sections, which seems to be everyone's complaint about SQL, but then you also have multiple types of brackets, colons and other syntax for no reason, all while not really accomplishing anything SQL doesn't already do. What's the attraction?

I don't use PRQL but I absolutely get the appeal but specifically on the readability part, some things that are easy in PRQL are just awful in SQL. From the website for instance this is a nightmare to do in SQL: from employees group role (sort join_date take 1)

What is the generated SQL of that expression?

This is indeed a sticky problem, one that usually requires a subselect or other workaround to address the non-determinism of group by + order by; i.e. one cannot simply "select * from employees group by role order by join_date limit 1" and be guaranteed to get the expected ordering.

Re: PRQL: Pipelined Relational Query Language

#139

The limitation of PRQL is that it only does SELECTs, by design. If you want to insert/update/delete data, you're back to SQL. That means that your team's data scientist might give you a query written in PRQL, but if you want to actually incorporate it into the data pipeline, you'll need to translate it into SQL. I wish that PRQL would support at least a limited ability to insert -- for example, maybe just the case of…

Yep, these is where I lost interest.

Re: PRQL: Pipelined Relational Query Language

#140
post #118

I really want this to take off and become a first party supported language for Postgres. Yes, yes, relational algebra is beautiful and all that jazz. SQL is a garbage, first pass design that should have been replaced decades ago. Even Codd has complaints about it. It is amazing what he invented, but we have learned a lot about PL design since then.

Not quite what you're asking for but DuckDB has both PRQL [1] and Postgres [2] extensions, so you could probably query your Postgres database with PRQL from there. There's also a DBeaver plugin [3] which we still need to document better and simplify the usage of but you could potentially also use that to query Postgres with PRQL. Finally there is pyprql [4] with which you could query Postgres from a Jupyter notebook.…

By first party I assume they mean using psql and postgres's own tooling.
Post reply on HN