Skip to content

validate: don't require an explicit geometry mapping for spatial layers - #588

Merged
teunbrand merged 2 commits into
posit-dev:mainfrom
cpsievert:fix/validate-spatial-geometry-autodetect
Oct 15, 2026
Merged

teunbrand merged 2 commits into
posit-dev:mainfrom
cpsievert:fix/validate-spatial-geometry-autodetect

Conversation

@cpsievert

Copy link
Copy Markdown
Collaborator

Fixes #587.

Fix

When a geom declares a geometry aesthetic, insert a placeholder mapping before the required-aesthetic check in schema-less validation, mirroring the execution-time contract (geometry is required, but may come from auto-detection). The placeholder is internal to the validation pass: Validated doesn't expose mappings, and execute_with_reader re-parses the query independently.

Alternative considered: an "auto-detectable" variant of DefaultAestheticValue, so the contract lives in geom metadata rather than a validate-side special case. Chose the minimal fix; happy to reshape.

Tests

  • test_validate_spatial_geometry_mapping_optional — spatial layer with and without an explicit geometry mapping.
  • test_validate_spatial_map_patterns — the canonical map patterns end-to-end through validate(): choropleth (join to ggsql:world, fill-only mapping), point map (null-sentinel fill, layer-level FROM, PROJECT TO), orthographic globe (SETTING origin). All rely on auto-detection.

Verified the issue's Rust repro prints valid = true / execute(): OK on this branch (vs valid = false / execute(): OK on main).

Found via querychat's maps capability, which pre-flight-validates LLM-generated queries with ggsql.validate().

The spatial geom declares the geometry aesthetic as required, but
execution auto-detects the geometry column from the result schema
(detect_geometry_column in execute/mod.rs). Schema-less validate() has
no schema to detect from, so it rejected any spatial query relying on
auto-detection with "Layer 'spatial' mapping requires the geometry
aesthetic" — a false rejection of queries that execute fine.

When a geom declares a geometry aesthetic, treat the mapping as
satisfied during schema-less validation, mirroring the execution-time
contract. Adds regression tests for the canonical map patterns
(choropleth, point map, orthographic globe), which all rely on
auto-detection.
@cpsievert
cpsievert force-pushed the fix/validate-spatial-geometry-autodetect branch from 9637bea to 85b0657 Compare October 14, 2026 15:01
@cpsievert
cpsievert marked this pull request as ready for review October 14, 2026 15:23
@cpsievert
cpsievert requested a review from teunbrand October 14, 2026 16:18
Comment thread src/validate.rs Outdated
@teunbrand
teunbrand merged commit 6741ac7 into posit-dev:main Oct 15, 2026
23 checks passed
@teunbrand

Copy link
Copy Markdown
Collaborator

Thanks for the fix Carson!

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.

validate() falsely rejects spatial queries that rely on geometry auto-detection

2 participants