apache / apache/sedona-db

chore: Handle unsupported geometries (e.g. point empty) in GeoExecutor

Open
#473 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
503
Forks
61
Avg merge
2d 5h
Merged PRs (30d)
91

Description

In multiple PRs implementing `geo` kernels (e.g. [1](https://github.com/apache/sedona-db/pull/469) and [2](https://github.com/apache/sedona-db/pull/233)), we've run across the [item_to_geometry()](https://github.com/apache/sedona-db/blob/e0e1d109480727faaf7be25923b57b4686144438/rust/sedona-geo/src/to_geo.rs#L62-L66) lack of support for certain geometries like point empty. The root of the problem is that `geo`'s methods simply return `None` for many of those cases.

In https://github.com/apache/sedona-db/pull/233#discussion_r2619908849, @paleolimbot proposed creating a new enum to allow the caller to access the WKB directly.

```rust
enum ItemToGeometryResult { Unsupported(Wkb), Supported(Geometry))
```

I thought about taking this one step further, what if we instead do something like this:

```rust
enum ItemToGeometryResult {
PointEmpty,
MultiPointEmpty, // we'd have to be extra careful here for cases like `MULTIPOINT (EMPTY, 1 0)`
Supported(Geometry),
Unsupported(Wkb), // or just continue allowing these cases to panic since these are complicated cases anyway
}
```

This would allow us to avoid re-parsing the Unsupported geom's bytes again to determine that it's an empty point/polygon. This should work because we *know* what method is returning the `None` inside of the following function

https://github.com/apache/sedona-db/blob/e0e1d109480727faaf7be25923b57b4686144438/rust/sedona-geo/src/to_geo.rs#L76-L87

Contributor guide

Open the contributing guide

Research direction

Start with rust/sedona-geo/src/to_geo.rs, especially item_to_geometry(), then inspect its GeoExecutor callers and the referenced PR discussions. Determine how empty points, empty multipoints, and other unsupported geometries should be represented without losing access to the original WKB. Done means the chosen behavior is implemented and the affected geo kernels handle these cases consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.