{"id":49382429,"url":"https://github.com/posit-dev/ggsql-duckdb","last_synced_at":"2026-04-30T08:00:53.261Z","repository":{"id":353562943,"uuid":"1218959474","full_name":"posit-dev/ggsql-duckdb","owner":"posit-dev","description":"A DuckDB extension adding support for ggsql ","archived":false,"fork":false,"pushed_at":"2026-04-25T14:21:38.000Z","size":408,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-28T06:33:07.772Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posit-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-23T11:42:47.000Z","updated_at":"2026-04-25T14:21:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/posit-dev/ggsql-duckdb","commit_stats":null,"previous_names":["posit-dev/ggsql-duckdb"],"tags_count":0,"template":false,"template_full_name":"duckdb/extension-template","purl":"pkg:github/posit-dev/ggsql-duckdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fggsql-duckdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fggsql-duckdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fggsql-duckdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fggsql-duckdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posit-dev","download_url":"https://codeload.github.com/posit-dev/ggsql-duckdb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fggsql-duckdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32414422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-28T06:05:17.625Z","updated_at":"2026-04-29T07:01:00.603Z","avatar_url":"https://github.com/posit-dev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ggsql DuckDB extension\n\nA DuckDB extension that routes `VISUALISE`/`VISUALIZE` statements through the [ggsql](https://ggsql.org) engine and renders vega-lite charts. The chart is served from an in-process HTTP server and opened in your default browser.\n\n## Building\n\n```sh\nmake\n```\n\nProduces:\n\n- `./build/release/duckdb` — DuckDB shell with the extension statically linked in (ready to use).\n- `./build/release/test/unittest` — the test runner, extension linked in.\n- `./build/release/extension/ggsql/ggsql.duckdb_extension` — the loadable binary for distribution.\n\nThe Rust staticlib (`rust/`) is built automatically by CMake; `cargo` must be on `PATH`. On macOS the extension links against `CoreFoundation`, `Security`, and `SystemConfiguration`.\n\n`vcpkg.json` has no C++ dependencies declared, so local builds don't require a vcpkg toolchain. CI builds do pick it up for overlay ports/triplets shared with the DuckDB extension CI.\n\n## Running the extension\n\nStart the shell with `./build/release/duckdb` — the extension is linked in. Or `LOAD ggsql;` against a regular DuckDB shell that has the loadable `.duckdb_extension` available.\n\nTwo surfaces are exposed:\n\n**ParserExtension — type ggsql directly:**\n```\nD SELECT 1 AS x, 2 AS y VISUALISE x, y DRAW point;\nD\n```\n\n(No output in silent mode, which is the default. The plot has been served to a browser tab.)\n\n**Scalar function — pass ggsql as a string:**\n```\nD SELECT ggsql('SELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line');\n```\n\nBoth forms open the default browser on the served URL. Set `GGSQL_NO_OPEN_BROWSER=1` in the environment to suppress the browser open (useful for tests and headless runs).\n\n### Output mode (`ggsql_output`)\n\nUse the session setting `ggsql_output` to choose what a query produces:\n\n| Value | Behaviour |\n|---|---|\n| `silent` *(default)* | Opens the default browser; the `VISUALISE` statement produces **no result set at all**. Good for interactive use — you see the plot, the shell doesn't spam a URL at you. |\n| `url` | Opens the browser and returns the plot URL in a 1×1 result. Good for scripts that want the URL. |\n| `spec` | Returns the raw vega-lite JSON as VARCHAR. No HTTP server, no browser. Good for piping to other tools. |\n| `html` | Returns a self-contained HTML document (~830 KB — vega + vega-lite + vega-embed inlined from the vendored bundles, plus the spec). No HTTP server, no browser. Good for saving a shareable snapshot: `COPY (SELECT ggsql('…')) TO 'plot.html'`. |\n\n```sql\n-- default: just see the plot, no shell output\nSELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line;\n\n-- get the URL back\nSET ggsql_output = 'url';\nSELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line;\n\n-- get the raw spec\nSET ggsql_output = 'spec';\nSELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line;\n-- → { \"$schema\": \"...\", \"data\": {...}, \"mark\": \"line\", ... }\n\n-- write a self-contained HTML file to disk\nSET ggsql_output = 'html';\nCOPY (SELECT ggsql('SELECT * FROM range(10) t(x) VISUALISE x, x*x AS y DRAW line')) TO 'plot.html';\n\nRESET ggsql_output;  -- back to silent\n```\n\nIn `url`/`spec`/`html` modes the result column is named `plot`, so wrapper queries (`SELECT plot FROM …`) keep working when the mode is toggled.\n\n## Session sharing (current limitation)\n\nggsql queries execute on a **fresh DuckDB connection** to the same database instance, not on the session that issued the query. This means ggsql can see:\n\n- Tables in attached `.duckdb` files\n- `CREATE VIEW` (non-temporary) definitions\n- Data under persistent catalogs\n\n...but **not**:\n\n- `CREATE TEMP TABLE` / `CREATE TEMP VIEW` defined in the current shell session\n- Per-session `SET` variables\n- Relations registered on the outer `Connection` from the client side (e.g. a Python `duckdb.register(...)`)\n\nSo this fails to find `flights`:\n\n```sql\nCREATE TEMP TABLE flights AS SELECT * FROM 'flights.csv';\nSELECT * FROM flights VISUALISE dep_delay, arr_delay DRAW point;  -- ❌ table not found\n```\n\nThe workaround is to use a regular view (or a real table in an attached DB):\n\n```sql\nCREATE OR REPLACE VIEW flights AS SELECT * FROM 'flights.csv';\nSELECT * FROM flights VISUALISE dep_delay, arr_delay DRAW point;  -- ✅\n```\n\nThe reason is structural: calling `Query` back into the outer `ClientContext` from inside an executing table function deadlocks on the context's mutex, so we open a sibling `Connection` — which by DuckDB's design has its own temp catalog.\n\n## Running the tests\n\nSQL logic tests under `test/sql/` are the primary test surface:\n\n```sh\nGGSQL_NO_OPEN_BROWSER=1 make test\n```\n\n`GGSQL_NO_OPEN_BROWSER=1` prevents a browser tab from opening for every test query.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposit-dev%2Fggsql-duckdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposit-dev%2Fggsql-duckdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposit-dev%2Fggsql-duckdb/lists"}