fix: rewrite double-quoted DuckDB sources in WASM#9925
Merged
mscolnick merged 1 commit intoJun 18, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes DuckDB WASM SQL remote-source rewrites when DuckDB readers (e.g. read_csv) are called with double-quoted URL arguments that sqlglot parses as quoted identifiers/columns rather than string literals. This ensures remote URL fetching/replacement-scan rewrites trigger correctly in Pyodide/WASM notebooks.
Changes:
- Normalize DuckDB “string-like” reader arguments by treating quoted identifiers/columns as string literal values for WASM source detection.
- Reuse the same normalization for option parsing so double-quoted string options don’t get rejected as dynamic.
- Add a regression test covering
read_csv("https://...")rewrite behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
marimo/_runtime/_wasm/_duckdb/sources.py |
Adds _string_literal_value() and uses it for reader source + option literal extraction, enabling double-quoted URL rewrites under sqlglot. |
tests/_runtime/test_duckdb_wasm.py |
Adds a unit test asserting wrapped_sql rewrites read_csv("https://...") and triggers the WASM fetch path. |
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant Test as UserTest
participant Wrapped as wrapped_sql()
participant Parser as SQLParser (sqlglot)
participant Rewriter as RewriteEngine
participant StringLit as _string_literal_value (NEW)
participant Fetch as fetch_url_bytes
participant DuckDB as DuckDB Connection
Test->>Wrapped: call wrapped_sql(read_csv("https://..."))
Wrapped->>Parser: parse SQL to AST
Parser-->>Wrapped: AST with read_csv Function
Wrapped->>Rewriter: rewrite_remote_sources(AST)
Rewriter->>Rewriter: find read_* functions
Rewriter->>Rewriter: _read_function_source(args[0])
Note over Rewriter: arg is exp.Column (double-quoted identifier)
Rewriter->>StringLit: _string_literal_value(exp.Column)
alt Identifier without table/db/catalog
StringLit->>StringLit: check quoted identifier
StringLit-->>Rewriter: "https://datasets.marimo.app/cars.csv"
else old behavior (Identifier not Literal)
Rewriter-->>Rewriter: would return None → raise error
end
Rewriter->>Rewriter: source is remote (https)
Note over Rewriter: NEW: rewrite to use fetch_url_bytes
Rewriter-->>Wrapped: rewritten SQL (fetches URL)
Wrapped->>Fetch: fetch_url_bytes(url)
Fetch-->>Wrapped: CSV bytes
Wrapped->>DuckDB: execute(SELECT FROM read_csv_auto(bytes))
DuckDB-->>Wrapped: relation
Wrapped-->>Test: relation rows
Note over Test,Fetch: Test asserts fetch_url_bytes called once
mscolnick
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up of #9480.
Fixes DuckDB WASM SQL rewrites for
read_csv("https://...")and otherread_*functions. DuckDB accepts double-quoted file sources, butsqlglotrepresents them as quoted identifiers not string literals, so we skipped the WASM remote-source rewrite and raised.This PR normalizes DuckDB string-like reader arguments before source validation.
Before
After