Commit 4712868
Spatial phase I: Layer (#370)
* grammatical accommodations
* Add Spatial geom type for choropleth/geographic visualization
Registers GeomType::Spatial across the parser, AST, and builder.
The spatial geom requires a `geometry` aesthetic and supports
fill, stroke, opacity, linewidth, and linetype.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add spatial feature: geometry auto-detection, geozero conversion, and SpatialRenderer
- Feature-gated `spatial` (default-on) with geozero + hex dependencies
- Auto-detect GEOMETRY columns via DESCRIBE for `DRAW spatial` layers
- SpatialRenderer converts WKB hex / GeoJSON strings to GeoJSON Features
- Vega-Lite geoshape mark with proper encoding channel handling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add spatial tests, fix geometry encoding, remove auto-detection
- Skip geometry aesthetic in encoding builder (structural, not visual)
- Remove SpatialRenderer::modify_encoding stub (default suffices)
- Remove geometry column auto-detection (revisit after Arrow migration)
- Add end-to-end tests: GeoJSON features, WKB hex, mixed layers
- Add execute test for explicit geometry mapping
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Allow arbitrary SQL setup statements (INSTALL, LOAD, SET, etc.)
Relax the grammar's other_sql_statement rule to accept any non-delimiter
tokens, so statements like INSTALL/LOAD/SET/ATTACH parse without error.
Execute these setup statements before the main query in the pipeline.
Flip DDL detection in DuckDB and SQLite readers to a returns_rows
whitelist, so unknown statement types are handled gracefully.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(reader): replace ColumnBuilder with direct Arrow export via query_arrow
DuckDB's query_arrow API exports results directly as Arrow RecordBatches,
eliminating the manual row-by-row type mapping. Extension types like
GEOMETRY now flow through as native Binary columns instead of hitting a
lossy string fallback. Decimal128 columns are normalized to Float64 at
the boundary for downstream compatibility.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(execute): use DDL instead of Arrow round-trip for temp table materialisation
Replaces the execute_sql() → register() two-step with direct
CREATE TEMP TABLE AS DDL. This keeps data inside the database engine
and preserves native types (e.g. DuckDB GEOMETRY) that were lost
during the Arrow materialisation round-trip.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(spatial): conditional ST_AsWKB stat transform and native GEOMETRY tests
Only apply ST_AsWKB when the geometry column is Binary (native DuckDB
GEOMETRY via Arrow). String columns (GeoJSON, WKB hex) pass through
to the writer unchanged.
Adds tests using INSTALL spatial; LOAD spatial with ST_GeomFromText
to verify the full native GEOMETRY pipeline end-to-end.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Revert "refactor(execute): use DDL instead of Arrow round-trip for temp table materialisation"
This reverts commit 2694724.
* refactor(spatial): remove string geometry paths, require native GEOMETRY
Remove GeoJSON/WKB hex string handling from the writer and stat
transform. Spatial data should come from native GEOMETRY columns
(via ST_Read, ST_GeomFromText, etc.), not string columns.
Drops hex crate dependency from the spatial feature.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(spatial): use dialect for geometry-to-WKB conversion
Add sql_geometry_to_wkb() to SqlDialect trait with ST_AsBinary
default (OGC standard). DuckDB overrides with ST_AsWKB. The spatial
stat transform uses the dialect instead of hardcoding.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(data): add ggsql:world built-in dataset
Natural Earth 110m country boundaries as geoparquet. Columns: name,
iso_a3, continent, subregion, income_group, population, gdp, geom.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(spatial): auto-load spatial extension via dialect
The spatial stat transform now calls dialect.sql_spatial_setup() before
emitting ST_AsWKB, so users no longer need manual LOAD spatial statements.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* cargo fmt
* feat(spatial): auto-detect geometry column by name and type
When a geom declares a geometry aesthetic and the user hasn't mapped it
explicitly, scan the schema for a column with a conventional geometry
name (geom, geometry, wkb_geometry, the_geom, shape) and binary type.
Requires exactly one match to avoid ambiguity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(spatial): load spatial extension before registering ggsql:world
DuckDB reads geoparquet geometry columns as BLOB when the spatial
extension is not loaded, making ST_AsWKB fail later. Pre-load spatial
when the world dataset is referenced so the column is read as GEOMETRY.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* override defaults chosen by claude
* add docs
* candles in pentagram shape for clippy
* beg for clippy's forgiveness
* try installing the spatial module during the test
* Apply suggestions from code review
Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>
* apply suggestions from code review
* cargo fmt
* Detect geometry columns via Reader::geometry_columns()
Geometry columns lose their native type during Arrow materialisation
(DuckDB GEOMETRY becomes plain Binary). Add Reader::geometry_columns()
that queries the backend's type system (DESCRIBE for DuckDB) to find
actual geometry columns, with a name+type heuristic fallback.
The detection is implemented as GeomTrait::detect_aesthetics(), which
spatial overrides. This runs after global mapping merge so user-declared
geometry mappings take precedence. Multiple native geometry columns are
treated as ambiguous (user must declare explicitly).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Revert "Detect geometry columns via Reader::geometry_columns()"
This reverts commit 0f42b58.
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>1 parent 0868fb0 commit 4712868
20 files changed
Lines changed: 630 additions & 62 deletions
File tree
- doc
- syntax
- layer/type
- ggsql-vscode/syntaxes
- src
- data
- execute
- parser
- plot/layer/geom
- reader
- writer/vegalite
- tree-sitter-ggsql
- queries
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| 192 | + | |
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | | - | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
Binary file not shown.
0 commit comments