Live data from Hacker News

Instant SQL for results as you type in DuckDB UI

motherduck.com

41–50 of 124 posts

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

#41
post #22

First time seeing the from at the top of the query and I am not sure how I feel about it. It seems useful but I am so used to select...from. I'm assuming it's more of a user preference like commas in front of the field instead of after field?

Yes it comes from a desire to impose intuition from other contexts onto something instead of building intuition with that thing. SQL is a declarative language. The ordering of the statements was carefully thought through. I will say it's harmless though, the clauses don't have any dependency in terms of meaning so it's fine to just allow them to be reordered in terms of the meaning of the query, but that's true of lo…

No, it comes from wanting to make autocompletion easier and to make variable scoping/method ordering make sense within LINQ. It is an actual improvement in this regard.

LINQ popularized it and others followed. It does what it says.

Btw: saying that "people try to impose their own comfort" is uncalled for.

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

#43
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

#44

This is such a bizarre feature.

What about it is bizarre?

It's probably different for duckdb, but from something like Microsoft SQL tossing off these random queries at a database of any size could have some weird performance impacts. For example statistics on columns you don't want them on, unindexed queries with slow performance, temp tables being dumped out to disk, etc.

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

#45

Edit: never mind, thanks for the replies! I had missed the part where it showed visualizing subqueries , which is what I wanted but didn't think it did. This looks very helpful indeed!

The article says it does subqueries:

> Getting the AST is a big step forward, but we still need a way to take your cursor position in the editor and map it to a path through this AST. Otherwise, we can’t know which part of the query you're interested in previewing. So we built some simple tools that pair DuckDB’s parser with its tokenizer to enrich the parse tree, which we then use to pinpoint the start and end of all nodes, clauses, and select statements. This cursor-to-AST mapping enables us to show you a preview of exactly the SELECT statement you're working on, no matter where it appears in a complex query.

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

#47
post #39
post #2

In DuckDB UI and MotherDuck. Awesome video of feature: https://youtu.be/aFDUlyeMBc8 Disclaimer: I’m a co-founder at MotherDuck.

Thanks for sharing this update with the world and including it on the local ui too. Feature request: enable the tuning of when Instant SQL is run and displayed. The erroring out with flashing updates at nearly every keystoke while expanding on a query is distracting for me personally (my brain goes into troubleshooting vs thinking mode). I like the feature (so I will keep it on by default), but I’d like to have a few…

Great feedback! Thanks. We agree w/ the red errors. It's not helpful when it feels like your editor is screaming at you.

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

#48
post #44

Earlier quoted context omitted.

What about it is bizarre?

It's probably different for duckdb, but from something like Microsoft SQL tossing off these random queries at a database of any size could have some weird performance impacts. For example statistics on columns you don't want them on, unindexed queries with slow performance, temp tables being dumped out to disk, etc.

I agree; one thing that is neat about Instant SQL is for many reasons, you can't do this with in any other DBMS. You really need DuckDB's specific architecture and ergonomics.

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

#49

Edit: never mind, thanks for the replies! I had missed the part where it showed visualizing subqueries , which is what I wanted but didn't think it did. This looks very helpful indeed!

> What would be helpful would be to be able to visualize intermediate results -- if my cursor is inside of a subquery, show me the results of that subquery.

But that's exactly what they show in the blog post??

Post reply on HN