Review a spatial SQL query with AI
Check the units, geographic relationship and join behaviour in an existing query. Get revised SQL and a small control case for the database you actually use.
To review a spatial SQL query with AI, start by describing what one output row should represent. Suppose an analyst wants the number of stops in each service zone. A stop on a shared boundary can match two zones or neither, depending on the predicate. The right query depends on what the count is meant to show.
The spatial-sql skill works with a database engine that has already been chosen. It examines coordinate systems, units and join conditions before suggesting changes. A small control set is part of the review when the engine is available, so you can distinguish an observed result from an untested suggestion.
What it does
- Check the units behind a distance threshold before applying it to geographic coordinates.
- Decide how a point shared by neighbouring polygons should count.
- Distinguish assigning a coordinate-system label from actually transforming the coordinates.
- Read the execution plan to see whether a spatial index helps this query.
- Try inside, outside and boundary samples before accepting a faster version.
Install and use
- Install the skill and provide the database engine, version, query and schema. Running a control requires authorised database access.
- Ask, “Why does this stop match twice? Review the boundary rule and show a small test on this engine.”
- Compare the result with the expected cases and keep unexecuted suggestions clearly marked.
FAQ
Source
Made by Jaak Laineste. Original skill: spatial-sql, published on GitHub under the MIT licence.
View on GitHub