apache / apache/sedona-db

c/sedona-s2geography: Points that lie exacty on a boundary may have different behaviour compared to BigQuery

Open
#817 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
503
Forks
61
Avg merge
2d 4h
Merged PRs (30d)
90

Description

I removed a few test cases when importing test cases from s2geography into our Python integration tests in https://github.com/apache/sedona-db/pull/816 .

```python
# Polygon contains interior sub-polygon with shared boundary
pytest.param(
"POLYGON ((0 0, 2 0, 0 2, 0 0))",
"POLYGON ((0 0, 0.5 0, 0 0.5, 0 0))",
True,
id="polygon_contains_interior_polygon",
),
# Linestring contains an interior point
pytest.param(
"LINESTRING (0 0, 1 0)",
"POINT (0.5 0)",
True,
id="linestring_contains_interior_point",
),
# Linestring contains an interior linestring
pytest.param(
"LINESTRING (0 0, 2 0)",
"LINESTRING (0 0, 1 0)",
True,
id="linestring_contains_interior_linestring",
),
```

The expected values above are BigQuery's result (and I believe the result that would be expected for the geometry case). PostGIS doesn't implement Contains for geography so we can't compare that (but it does implement covers).

One of the tricky things about non-vertex boundaries in Geography is that it is exceedingly rare for a point to be exactly on a great circle between two vertices...these test cases are contrived but do expose a hole in the s2geography testing (I am not sure there's a good test case for the difference between contains and covers where the vertices are exactly the same).

Contributor guide

Open the contributing guide

Research direction

Start with the Python integration tests and the cases removed in PR 816; compare their expected BigQuery results with current s2geography behavior for boundary points and contains semantics. Determine the intended handling for the listed polygon and linestring cases, then add focused coverage and verify the tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.