Skip to content

Conversation

@Abeeujah
Copy link
Contributor

Having read both Issue #244 and PR #243 I'm quite interested in knowing or having the test cases that SedonaDB and PostGIS diverge, before I proceed to do a custom implementation, but at the moment, It seems to look fine on my end;
Everything is up for review.

closes #244

@paleolimbot paleolimbot changed the title ST_Simplify feat(c/sedona-geos): Implement ST_Simplify Nov 11, 2025
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few optional notes to consider...thank you for the thorough test cases!

Comment on lines 93 to 94

let geometry = match (initial_type, geometry.geometry_type()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let geometry = match (initial_type, geometry.geometry_type()) {
// GEOS simplifies MultiPolygon/MultiLineString to Polygon/Linestring; however, we
// attempt to keep the original geometry type for PostGIS compatibility.
let geometry = match (initial_type, geometry.geometry_type()) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: It might be nice to explain why we need the wrapper!

Comment on lines +127 to +129

#[rstest]
fn udf(#[values(WKB_GEOMETRY, WKB_VIEW_GEOMETRY)] sedona_type: SedonaType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all of these test cases! Are there any sources we should acknowledge for them? (May be useful to update our own tests at some point if there are sources you consulted!)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of rust tests. FYI, for the future, you can be a little light on Rust tests, since they're kind of verbose. The python tests (which are very concise) is where we try to be comprehensive. e.g I'll often include a single empty geom in Rust tests, while in Python I'll test empty geoms for all types.

There's no need to delete these. Just mentioning it for the future because I know it can be kind of annoying to write so many of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all of these test cases! Are there any sources we should acknowledge for them? (May be useful to update our own tests at some point if there are sources you consulted!)

The implementation is based on the Spec defined in POSTGIS I run the test cases specified there manually on the docker container, then proceed to assert in code that the behavior is compliant.

Another place I consult for the test cases is Geos test suite ST_Simplify

Copy link
Contributor Author

@Abeeujah Abeeujah Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of rust tests. FYI, for the future, you can be a little light on Rust tests, since they're kind of verbose. The python tests (which are very concise) is where we try to be comprehensive. e.g I'll often include a single empty geom in Rust tests, while in Python I'll test empty geoms for all types.

I find it easier to test in Rust, especially as it's strongly typed, for Instance, POSTGIS amd Sedona tend to handle EMPTY differently when testing with python, Sedona returns EMPTY while POSTGIS returns None, would require me including conditional checks in test function to get them to coexist happily, but Rust Serializes and Deserializes it Just fine.

But yeah, I'd be a little light on the Rust tests, and focus testing energy on Python's

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful for us to have the Rust tests because we'd like to implement a faster version at some point, and when we have Rust code we'll need the Rust tests to cover the behaviour. (But yes, the minimum requirement for wrapping external library behaviour is a "is it plugged in" check at the Rust level).

@paleolimbot paleolimbot merged commit 112d3c8 into apache:main Nov 12, 2025
12 checks passed
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.

Implement ST_Simplify()

3 participants