Skip to content

Conversation

@Abeeujah
Copy link
Contributor

closes #199

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.

Thank you!

A few optional things to consider, but in general this looks good to me!

We also include integration tests for all our functions in Python (to check against PostGIS). It would be helpful if you did that here, but it is also no problem if you prefer not to (you or one of us can create a follow-on issue to ensure we do it at some point). These integration tests will be very similar to the other predicate integration tests:

@pytest.mark.parametrize("eng", [SedonaDB, PostGIS])
@pytest.mark.parametrize(
("geom1", "geom2", "expected"),
[
(None, None, None),
("POINT (0 0)", None, None),
(None, "POINT (0 0)", None),
("POINT (0 0)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", True),
("POINT (0.5 0.5)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", True),
("POINT (0 0)", "POINT EMPTY", False),
("POINT (0 0)", "LINESTRING (0 0, 1 1)", True),
("LINESTRING (0 0, 1 1)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", True),
(
"POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))",
"POLYGON ((5 5, 6 5, 6 6, 5 6, 5 5))",
False,
),
(
"POINT (1 1)",
"GEOMETRYCOLLECTION (POINT (0 0), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), LINESTRING (0 0, 1 1))",
True,
),
],
)
def test_st_covered_by(eng, geom1, geom2, expected):
eng = eng.create_or_skip()
eng.assert_query_result(
f"SELECT ST_CoveredBy({geom_or_null(geom1)}, {geom_or_null(geom2)})",
expected,
)

...and some instructions on how to get started with the Python package are here: https://github.com/apache/sedona-db/blob/main/docs/contributors-guide.md#python

Comment on lines 454 to 462
let arg2 = create_array(
&[
Some("POLYGON ((1 1, 1 3, 3 3, 3 1, 1 1))"),
Some("LINESTRING (1 0, 3 0)"),
Some("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))"),
],
&WKB_GEOMETRY,
);
let expected: ArrayRef = arrow_array!(Boolean, [Some(true), Some(true), None]);
Copy link
Member

Choose a reason for hiding this comment

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

I think this test would be more useful if one of the results were false

}
}

/// Check if the geometries crosses
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
/// Check if the geometries crosses
/// Check if the geometries cross

}
}

/// Check if the geometries overlaps
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
/// Check if the geometries overlaps
/// Check if the geometries overlap

@jiayuasu
Copy link
Member

Great work!

@paleolimbot
@Kontinuation

how do these functions work with our current spatial join implementation?

@Kontinuation
Copy link
Member

how do these functions work with our current spatial join implementation?

Spatial join has its own spatial predicate evaluators for statistics awareness and better performance; UDF implementations of these predicates have no impact on spatial join.

@Abeeujah
Copy link
Contributor Author

Hi @paleolimbot My bad, I was following the reference PR mentioned in the issue description, it didn't seem to include integrated tests on the python side, but I've currently implemented that, I'd love you to give it a look again,

For the nitpick suggestions/comments in the rust side, I've resolved them again as well, looking forward to getting a review at your earliest.

@jiayuasu and @Kontinuation Thank y'all so much for the kind words!

@petern48
Copy link
Collaborator

My bad, I was following the reference PR mentioned in the issue description, it didn't seem to include integrated tests on the Python side, but I've currently implemented that, I'd love you to give it a look again

Yeah, this is my fault for not mentioning it in the issue, not yours. We added the integration test suite completely after all of the other predicates. Great job on adding them.

Comment on lines +410 to +413
("POINT (0 0)", "POINT (0 0)", False),
("LINESTRING (0 0, 2 2)", "LINESTRING (1 1, 3 3)", True),
("LINESTRING (0 0, 1 1)", "LINESTRING (0 1, 1 0)", False),
("LINESTRING (0 0, 1 1)", "LINESTRING (1 1, 2 2)", False),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that we have some good edge cases here like identical geometries ("POINT (0 0)", "POINT (0 0)") and "touching geometries" (i.e. "LINESTRING (0 0, 1 1)", "LINESTRING (1 1, 2 2)")

[
(None, None, None),
("POINT (0 0)", None, None),
(None, "POINT (0 0)", None),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
(None, "POINT (0 0)", None),
(None, "POINT (0 0)", None),
("POINT (0 0)", "POINT EMPTY", False),

How about we add one more case (empty geometries) while we're here. I checked out the branch and tested these locally, and saw that they already pass.

[
(None, None, None),
("POINT (0 0)", None, None),
(None, "POINT (0 0)", None),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
(None, "POINT (0 0)", None),
(None, "POINT (0 0)", None),
("POINT (0 0)", "POINT EMPTY", False),

@Abeeujah
Copy link
Contributor Author

@petern48 it's all cool, your issue description and the PR linked was super helpful, gave me enough context to raise a PR, Thank you for that.

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.

Thank you @Abeeujah (and thank you @petern48 for the review!) 🚀

@paleolimbot paleolimbot merged commit 5493b8e into apache:main Oct 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.

feat: Implement ST_Crosses and ST_Overlaps predicates

5 participants