Add ST_IsValid and ST_MakeValid for geography
- Dominant language
- Rust
- Stars
- 503
- Forks
- 61
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 90
Description
## Description
Follow-up to #1085 and #1143.
`ST_GeogFromWKB`/`ST_GeogFromWKT` currently accept rings whose edges cross when interpreted as geodesics, and geography behaviour for such input is undefined. #1143 makes the default ring-orientation heuristic less surprising for that kind of input, but the principled path is to detect and repair it:
- `ST_IsValid(geography)` — report whether the input is a valid spherical geography (e.g., no crossing edges), so pipelines can find problem geometries like the Overture division boundary in #1085 (its planar interpretation is valid; only the geodesic interpretation self-intersects).
- `ST_MakeValid(geography)` — rebuild the input into a valid geography (e.g., via an S2Builder snap/repair pass), so joins and measures are well defined afterwards.
For context, the BigQuery comparison checks already had to work around this class of input by using a "make valid" WKB constructor because at least one polygon in the test corpus fails validation with a crossing-edges error (see discussion in #1085).
Contributor guide
Research direction
Start by tracing the existing geography function entry points and the BigQuery comparison checks referenced in #1085. Investigate how an S2Builder snap/repair pass could support ST_IsValid and ST_MakeValid. Done means crossing-edge geographies can be detected and repaired so subsequent joins and measures have defined behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100