Skip to content

flatten SQL fragments in DuckDBClient.sql - #197

Merged
Fil merged 2 commits into
mainfrom
fil/duckdb-sql
Oct 8, 2026
Merged

Fil merged 2 commits into
mainfrom
fil/duckdb-sql

Conversation

@Fil

@Fil Fil commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

DuckDBClient.sql now flattens SQL fragments before it runs the query. Fragments, views (sql.view), and variants (sql.variant, sql.ident) now work with DuckDB.

@Fil
Fil requested a review from mbostock October 6, 2026 11:04

@mbostock mbostock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems right functionally. But I wonder how the bundling works because sql.js is normally bundled with the runtime and duckdb.js is imported dynamically… I think this means that sql.js has to be bundled separately from the rest of the runtime, which might make loading the standard library slightly slower…

One alternative would be that we have to pass in the sql implementation when loading DuckDBClient (and by that I mean internally, when Notebook Kit calls import("./duckdb.js"); this would not be an obligation of the user)… but that’s tricky.

Another alternative would be to do a dynamic import of ./sql.js in src/runtime/stdlib/index.ts… Then you only pay the latency cost when you are using DatabaseClient or DuckDBClient which is likely the way to go.

@Fil

Fil commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Aren't we already loading and running sql.js? Since we're doing an export {sql} from "./stdlib/sql.js"?

@Fil

Fil commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

So I guess I just revert 81f11c4 ?

@Fil
Fil merged commit 23fb336 into main Oct 8, 2026
1 check passed
@Fil
Fil deleted the fil/duckdb-sql branch October 8, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants