News for hackers. Stuff that matters.
Re:Instant SQL for results as you type in DuckDB UI by jakozaur on Thursday April 24, 2025 @12:19PM (#43784523)
It would be even better if SQL had pipe syntax. SQL is amazing, but its ordering isn’t intuitive, and only CTEs provide a reliable way to preview intermediate results. With pipes, each step could clearly show intermediate outputs.

Example:

FROM orders |> WHERE order_date >= '2024-01-01' |> AGGREGATE SUM(order_amount) AS total_spent GROUP BY customer_id |> WHERE total_spent > 1000 |> INNER JOIN customers USING(customer_id) |> CALL ENRICH.APOLLO(EMAIL > customers.email) |> AGGREGATE COUNT(*) high_value_customer GROUP BY company.country

Re:Instant SQL for results as you type in DuckDB UI by tstack on Thursday April 24, 2025 @02:22PM (#43785829)
The PRQL[1] syntax is built around pipelines and works pretty well.

I added a similar "get results as you type" feature to the SQLite integration in the Logfile Navigator (lnav)[2]. When entering PRQL queries, the preview will show the results for the current and previous stages of the pipeline. When you move the cursor around, the previews update accordingly. I was waiting years for something like PRQL to implement this since doing it with regular SQL requires more knowledge of the syntax and I didn't want to go down that path.

[1] - https://prql-lang.org [2] - https://lnav.org/2024/03/29/prql-support.html

Re:Instant SQL for results as you type in DuckDB UI by mritchie712 on Thursday April 24, 2025 @02:50PM (#43786107)
Re:Instant SQL for results as you type in DuckDB UI by RyanHamilton on Thursday April 24, 2025 @05:23PM (#43787665)
If you want to get started with prql check out qstudio https://www.timestored.com/qstudio/prql-ide it allows running prql easily against mysql postgresql duckdb etc
Re:Instant SQL for results as you type in DuckDB UI by hamilton on Thursday April 24, 2025 @01:24PM (#43785202)
Obviously one advantage of SQL is everyone knows it. But conceptually, I agree. I think [1]Malloy is also doing some really fantastic work in this area.

This is one of the reasons I'm excited about DuckDB's upcoming [2]PEG parser. If they can pull it off, we could have alternative dialects that run on DuckDB.

[1] https://www.malloydata.dev/ [2] https://duckdb.org/2024/11/22/runtime-extensible-parsers.htm...

Re:Instant SQL for results as you type in DuckDB UI by metadata on Thursday April 24, 2025 @01:16PM (#43785112)
Google SQL has it now:

https://cloud.google.com/blog/products/data-analytics/simpli...

It's pretty neat:

    FROM mydataset.Produce
    |> WHERE sales > 0
    |> AGGREGATE SUM(sales) AS total_sales, COUNT(\*) AS num_sales
       GROUP BY item;
Edit: formatting
Re:Instant SQL for results as you type in DuckDB UI by ryguyrg on Thursday April 24, 2025 @01:39PM (#43785370)
note that DuckDB allows that reverse ordering (FROM-first)

FROM table SELECT foo, bar WHERE zoo=“goo”

Re:Instant SQL for results as you type in DuckDB UI by viggity on Thursday April 24, 2025 @03:21PM (#43786443)
it makes intellisense/autocomplete work a hell of a lot easier. LINQ in dotnet does the same thing.
Re:Instant SQL for results as you type in DuckDB UI by crooked-v on Thursday April 24, 2025 @01:19PM (#43785156)
I suspect you'll like PRQL: https://github.com/PRQL/prql
Re:Instant SQL for results as you type in DuckDB UI by wodenokoto on Thursday April 24, 2025 @01:46PM (#43785451)
I haven’t tested but I believe there’s a prql extension for duckdb
Re:Instant SQL for results as you type in DuckDB UI by cdchhs on Thursday April 24, 2025 @09:50PM (#43789406)
that syntax is horrendous.
Re:Instant SQL for results as you type in DuckDB UI by da_chicken on Thursday April 24, 2025 @09:50PM (#43789407)
While I would certainly agree with you that putting the FROM clause first would be a significant improvement to SQL and was a genuine design mistake, this otherwise feels more like just wanting SQL to be less declarative and more imperative. Wanting it to be more like LINQ and less like relational algebra.

That, I think, is most developers' real sticking point with SQL. It's not object-relational impedance mismatch between their application and the data store, it's imperative-declarative impedance mismatch between their preferred or demonstrated talent. They are used to thinking about problems in exactly one way, so when they struggle to adapt to a different way of thinking about the problems they assume their familiarity is what's more correct.

I think this is why the same developers insist that XML/HTML is "just a markup language." Feeding a document into an executable to produce output isn't really significantly different than feeding imperative language into a compiler. The only real difference is that one is Turing complete, but Turning completeness is not a requirement of programming languages.

Re:Instant SQL for results as you type in DuckDB UI by NDizzle on Friday April 25, 2025 @08:30AM (#43792881)
This is the stuff nightmares are made out of. Keep that style of coding out of any project I’m involved in, please.
Re:Instant SQL for results as you type in DuckDB UI by sidpatil on Friday April 25, 2025 @09:39AM (#43793455)
What do you dislike about that style?
Re:Instant SQL for results as you type in DuckDB UI by bb86754 on Friday April 25, 2025 @10:40AM (#43794086)
He/she isn't used to it. Any R, Elixir, or F# developer would be right at home with this syntax.