Repository navigation
Conversation
> Look at most recent branches in simonw/research - the rust SQLite extension for SPARQL > Compile that extension to WASM and get it working with WASM SQLite, then build an HTML > playground UI for people to try it out with plenty of examples sqlite-sparql/ builds sparqlite (simonw/research, branch claude/sqlite-sparql-rust) for wasm32-unknown-emscripten as a static library and links it into SQLite 3.54.0's official WASM build (the sqlite3.mjs ES module) through SQLite's sqlite3_wasm_extra_init.c hook, registered with sqlite3_auto_extension so every connection gets the sparql_* functions. build_wasm.sh rebuilds it from pinned sources. Needed along the way: -fwasm-exceptions (Rust unwinds panics with WASM exceptions), a wasm-opt wrapper adding --disable-compact-imports (current Binaryen otherwise emits an import encoding browsers reject), and a two-hunk patch so sparqlite never spawns threads. sqlite-sparql.html runs it in a Web Worker on the sparqlite tutorial dataset (94 real programming languages plus fictional survey graphs and a job_postings SQL table), with 68 examples across SPARQL queries, property paths, named graphs, CONSTRUCT/DESCRIBE, updates and the SQL functions and virtual tables, plus explain, output formats, engine choice, click-to-explore IRIs, RDF loading, database download/upload and a Stop button that restores the last database snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VY9i6itsA8uV3tGCNf5Ppb
This branch has not been deployed
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.
Adds
sqlite-sparql.html, a browser playground for sparqlite, the Rust SQLite extension that implements SPARQL 1.1 (from simonw/research, branchclaude/sqlite-sparql-rust, pinned to commit70cbd8b).The WASM build (
sqlite-sparql/)wasm32-unknown-emscripten. It is linked into SQLite 3.54.0's official WASM build (the standardsqlite3.mjswith theoo1/capiAPI) through SQLite's documentedsqlite3_wasm_extra_init.chook, with no makefile patching.sqlite3_auto_extension, so every connection gets thesparql_*functions and thesparql_rows/sparql_viewvirtual tables.sqlite3.wasmis 4.4 MB (1.7 MB gzipped) andsqlite3.mjsis 440 KB (94 KB gzipped).build_wasm.shrebuilds everything from pinned sources. The committed files are the output of a from-scratch run, which included a fresh Emscripten 6.0.12 install.sqlite-sparql/README.md):-fwasm-exceptions: Rust's emscripten target unwinds panics with WASM exceptions. sparqlite's panic containment works in the browser: a deliberate panic surfaces as a SQL error and the connection keeps working.wasm-optwrapper adding--disable-compact-imports: SQLite's makefile runswasm-opt --all-features, and the current Binaryen (version 133) then writes imports in an encoding that browsers reject ("unknown import kind 0x7f"). This affects any SQLite WASM build made with current emsdk.wasm-threads.patch: WASM has no threads. RDF inputs over 1 MiB are now parsed inline, and the watchdog for theengine=sqltimeout is skipped. The deadline is still checked between row batches.:memory:, which made scan-heavy queries 2–3× faster.The playground (
sqlite-sparql.html)job_postingsSQL table.sparql_rows,sparql_view, joins with SQL tables, views, transactions, storage tables,sparql_explain, SPARQL→SQL translation, settings, timeouts and errors.#sparql=/#sql=links;Tests
tests/test_sqlite_sparql.pyhas 17 Playwright tests, all passing locally in headless Chromium. One clicks through all 68 examples and checks that only the two intentional-error examples fail. Others cover each of the playground features above.Known issue (upstream)
The spargebra 0.4.7 SPARQL parser takes exponential time on nested
!( !( … ) ): about 1 s at depth 20, natively too. The worker and the Stop button keep the page usable when it happens.🤖 Generated with Claude Code
https://claude.ai/code/session_01VY9i6itsA8uV3tGCNf5Ppb
Generated by Claude Code