Live data from Hacker News

Instant SQL for results as you type in DuckDB UI

motherduck.com

51–60 of 124 posts

Re: Instant SQL for results as you type in DuckDB UI

#51

I really like duckdb's notebooks for exploration and this feature makes them even more awesome, but the fact that I can't share, export or commit them into a git repo feels extremely limiting. It's neat-ish that it dodfoods and store them in a duckdb database. It even seems to stores historical versions, but I can't really do anything with it..

Definitely something we want too! (I'm the author / lead for the UI)

Re: Instant SQL for results as you type in DuckDB UI

#52

Please finally add q language with proper integration to your tables so that our precious q-SQL is available there. Stop reinventing the wheel, let's at least catch up to the previous generation (in terms of convenience). Make the final step.

What is q-SQL?

https://code.kx.com/q/basics/qsql/

Re: Instant SQL for results as you type in DuckDB UI

#53

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(custome…

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

#54

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(custome…

I suspect you'll like PRQL: https://github.com/PRQL/prql

Re: Instant SQL for results as you type in DuckDB UI

#55

Earlier quoted context omitted.

The blog specifically says that they're getting the SQL AST so presumably they would not execute something like a DELETE.

Correct. We only enable fast previews for SELECT statements, which is the actual hard problem. This said, at some point we're likely to also add support for previewing a CTAS before you actually run it.

I remember your demos of visualizing the CTEs of a huge query in the editor. I'm looking forward to trying it!

Re: Instant SQL for results as you type in DuckDB UI

#56

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(custome…

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

#57

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(custome…

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

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

#58
post #23

Earlier quoted context omitted.

It is already available in the local DuckDB UI! Let us know what you think! -Customer software engineer at MotherDuck

Does local DuckDB UI work without an internet connection?

I’m pretty sure it doesn’t. My understanding is it gets downloaded at startup and then runs offline.

Kinda like regex101, draw.io or excalidraw.

Re: Instant SQL for results as you type in DuckDB UI

#59
post #7
post #4

I hope this doesn't work with DELETE queries.

Maybe in the next version they could also implement support for DROP, with autocorrect for the nearest (not yet dropped) table name.

Or, for extra fun, it auto completes to DROP TRIGGER and just drops a single random trigger from your database. It'll help counter automation fears by ensuring your DBAs get to have a wonderful weekend on payroll where, very much in the easter spirit, they can hunt through the DB looking for the one thing that should be there but isn't!

Re: Instant SQL for results as you type in DuckDB UI

#60

I just watched the author of this feature and blog post give a talk at the DataCouncil conference in Oakland, and it is obvious what a huge amount of craft, ingenuity, and care went into building it. Congratulations to Hamilton and the MotherDuck team for an awesome launch!

Is that talk available online?
Post reply on HN