by heydenberk on 8/25/24, 1:33 PM with 182 comments
by samwillis on 8/28/24, 10:13 PM
Worth reading the thread, there are some good insights. It looks like he will be waiting on Postgres to take the initiative on implementing this before it makes it into a release.
by tehlike on 8/28/24, 10:50 PM
While LINQ is mostly restricted to .NET, PRQL is not. https://prql-lang.org/
It's a welcome change in the industry.
I made this prediction a couple years back: https://x.com/tehlike/status/1517533067497201666
by aragonite on 8/29/24, 1:57 AM
I've never understood why copying text from digitally native PDFs (created directly from digital source files, rather than by OCR-ing scanned images) is so often such a poor experience. Even PDFs produced from LaTex often contain undesirable ligatures in the copied text like fi and fl. Text copied from some Springer journals sometimes lacks space between words or introduces unwanted space between letters in a word ... Is it due to something inherent in PDF technology?
by summerlight on 8/28/24, 10:00 PM
https://news.ycombinator.com/item?id=41321876 (first) https://news.ycombinator.com/item?id=41338877 (plenty of discussions)
I tried this new syntax and this seems a reasonable proposal for complex analytical queries. This new syntax probably does not change most simple transactional queries though. The syntax matches the execution semantic more closely, which means you less likely need to formulate query in a weird form to make query planner work as expected; usually users only need to move some pipe operators to more appropriate places.
by BeefWellington on 8/29/24, 4:17 AM
Just for once I want to see complete examples of the syntax on an actual advanced query of any kind right away. Sure, toss out one simple case, but then show me how it looks when I have to join 4-5 reference tables to a fact table and then filter based on those things.
Once you do that, it becomes clear why SELECT first won out originally: legibility and troubleshooting.
As long as DBs continue to support standard SQL they can add whatever additional syntax support they want but based on history this'll wind up being a whole new generation of emacs vs vi style holy war.
by urbandw311er on 8/28/24, 9:44 PM
by yarg on 8/28/24, 10:40 PM
There was a talk at the time, but I can't find the video: http://jaoo.dk/aarhus2007/presentation/Using+LINQ+to+SQL+to+....
Basically, it was a way to cleanly plug SQL queries into C# code.
It used this sort of ordering (where the constraints come after the thing being constrained); it needed to do so for IntelliSense to work.
by mav3ri3k on 8/29/24, 6:13 AM
Google has now proposed a syntax inspired by these approaches. However, I am afraid how well it would be adopted. As someone new to SQL, nearly every DB seem to provide its own SQL dialect which becomes cumbersome very quickly.
Whereas PRQL feels something like Apache Arrow which can map to other dialects.
by 0xbadcafebee on 8/29/24, 3:01 AM
by slaymaker1907 on 8/28/24, 10:30 PM
by donatj on 8/29/24, 4:50 AM
Also it would make autocomplete in intelligent IDEs much more helpful when typing a query out from nothing.
by victorbjorklund on 8/29/24, 6:51 AM
"users" |> where([u], u.age > 18) |> select([u], u.name)
by chubot on 8/29/24, 12:09 AM
I pointed out that you can do this with shell:
Pipelines Support Vectorized, Point-Free, and Imperative Style https://www.oilshell.org/blog/2017/01/15.html
e.g.
hist() {
sort | uniq -c | sort -n -r
}
$ { echo a; echo bb; echo a; } | hist
1 bb
2 a
$ foo | hist
...
Something like that should be possible in SQL!by wvenable on 8/29/24, 5:32 AM
GROUP AND ORDER BY component_id DESC;
Is this kind of syntax combining grouping and ordering really necessary in addition the pipe operator? My advice would be to add the pipe operator and not get fancy adding other syntax to SQL as well.by minkles on 8/29/24, 7:30 AM
flights |>
filter(
carrier == "UA",
dest %in% c("IAH", "HOU"),
sched_dep_time > 0900,
sched_arr_time < 2000
) |>
group_by(flight) |>
summarize(
delay = mean(arr_delay, na.rm = TRUE),
cancelled = sum(is.na(arr_delay)),
n = n()
) |>
filter(n > 10)
If you haven't used R, it has some serious data manipulation legs built into it.by AdieuToLogic on 8/28/24, 11:39 PM
https://leanpub.com/combinators/read#leanpub-auto-the-thrush
Being a concept which transcends programming languages, a search for "thrush combinator" will yield examples in several languages.
by Ericson2314 on 8/29/24, 2:42 AM
Right now, it's everyone faffing around with different mental models and ugly single pass compilers (my understanding is that parsing-->query planning is not nearly as well-separated in most DBs as parsing-->optomize-->codegen in most compilers).
by verdverm on 8/28/24, 9:58 PM
by Zopieux on 8/29/24, 9:17 PM
Syntax/DSL designers: if your language uses a separator for anything, please kindly allow trailing versions of that separator anywhere possible.
by themerone on 8/29/24, 12:42 AM
by gopiandcode on 8/29/24, 7:09 AM
https://github.com/kiranandcode/petrol
An example query being:
```
let insert_person ~name:n ~age:a db = Query.insert ~table:example_table ~values:Expr.[ name := s n; age := i a ] |> Request.make_zero |> Petrol.exec db
```
by KronisLV on 8/29/24, 6:38 AM
by middayc on 8/29/24, 8:40 AM
FROM customer
|> LEFT OUTER JOIN orders ON c_custkey = o_custkey
AND o_comment NOT LIKE '%unusual%packages%'
|> AGGREGATE COUNT(o_orderkey) c_count
GROUP BY c_custkey
|> AGGREGATE COUNT(*) AS custdist
GROUP BY c_count
|> ORDER BY custdist DESC, c_count DESC;
You could do something similar with Ryelang's spreadsheet datatype: customers: load\csv %customers.csv
orders: load\csv %orders.csv
orders .where-not-contains 'o_comment "unusual packages"
|left-join customers 'o_custkey 'c_custkey
|group-by 'c_custkey { 'c_custkey count }
|group-by 'c_custkey_count { 'c_custkey_count count }
|order-by 'c_custkey_count_count 'descending
Looking at this, maybe we should add an option to name the new aggregate column (now they get named automatically) in group-by function because c_custkey_count_count is not that elegant for example.by rileymat2 on 8/28/24, 10:57 PM
I like the syntax for reading what the statement expects to output first, even though I agree that I don’t write them select first. I feel like this might be optimizing the wrong thing.
Although the example is nice, it does not show 20 tables joined first, which will really muddle it.
by delegate on 8/29/24, 8:57 AM
{:select [:name :age]
:from {:people :p}
:where [:> :age 10]}
Since maps are unordered, this is equivalent to {:from {:people :p}
:select [:name :age]
:where [:> :age 10]}
and also {:where [:> :age 10]
:select [:name :age]
:from {:people :p}}
These can all be rendered to 'SELECT... FROM' or 'FROM .. SELECT'.Queries as data structures are very versatile, since you can use the language constructs to compose them.
Queries as strings (FROM-first or not) are still strings which are hard to compose without breaking the syntax.
by OptionOfT on 8/29/24, 8:18 PM
This feels like too much. GROUP BY and ORDER BY are separate clauses, and creating a way to group (heh) them in one clause complicates cognitive load, especially when there is an effort to reduce the overall effort to parse the query in your mind (and to provide a way for an intellisense-like system a way to make better suggestions).
GROUP AND ORDER BY x DESC;
vs GROUP BY x;
ORDER BY x DESC;
This long form is 1 word longer, but, it easier to parse in your mind, and doesn't introduce unneeded diffs when changing either the GROUP or the ORDER BY column reference.by isoprophlex on 8/29/24, 6:35 AM
|>
What IS that thing? A unix pipe that got confused with a redirect? A weird smiley of a bird wearing sunglasses?It'll take some getting used to, for me...
by OscarCunningham on 8/29/24, 8:02 AM
I think this is bad rationale. Having the columns in order is much more important than having neat syntax for full-table aggregation.
by philippta on 8/29/24, 6:43 AM
If the DB engine is executing the statement out of order, why not allow the statement to be written in any order and let itself figure it out?
by julien040 on 8/29/24, 7:15 AM
It's inspired by Kusto and available as an open-source CLI. I've made it compatible with SQLite in one of my tools, and it's refreshing to use.
An example:
StormEvents
| where State startswith "W"
| summarize Count=count() by State
by eezing on 8/29/24, 7:03 AM
by nagisa on 8/29/24, 8:09 AM
by ahmed_ds on 8/29/24, 9:13 AM
by aloukissas on 8/29/24, 6:44 AM
[1] https://elixirschool.com/en/lessons/basics/pipe_operator
by stevefan1999 on 8/29/24, 6:16 AM
by dang on 8/29/24, 5:14 AM
Pipe Syntax in SQL - https://news.ycombinator.com/item?id=41338877 - Aug 2024 (219 comments)
by datadeft on 8/29/24, 7:26 AM
Is it though?
Are we trying to solve the human SQL parser and generator problem or there is some underlying implementation detail that benefits from pipes?
by eternauta3k on 8/29/24, 5:10 AM
by oznog on 8/29/24, 10:46 PM
SQL is fine.
SQL has been the state of the art for db queries for 40 years.
And it will continue to be when we all retire.
by jiggawatts on 8/29/24, 6:49 AM
by metadat on 8/29/24, 12:31 AM
by carabiner on 8/29/24, 1:32 AM
by fridental on 8/29/24, 8:29 AM
LINQ: exists
Splunk query language: exists
KQL: exists
MongoDB query language: exists
PRQL: exists
by 1024core on 8/29/24, 2:40 AM
by notfed on 8/29/24, 1:12 AM
by make3 on 8/29/24, 4:03 AM
by rosencrantz on 8/30/24, 8:15 PM
// but let's change it to *int ptr;
// because the pointer symbol is more logical to write first
Please can we solve a real problem instead?
by jappgar on 8/29/24, 12:06 PM
by thenegation on 8/29/24, 1:08 AM
https://cs.brown.edu/~sk/Publications/Papers/Published/rk-st...
by sharpshadow on 8/29/24, 1:42 PM