Skip to content

Conversation

@2010YOUY01
Copy link
Contributor

@2010YOUY01 2010YOUY01 commented Jan 21, 2026

Rationale

ST_GeomFromWKBUnchecked() is equivalent to ST_GeomFromWKB(), but it skips validation during conversion.

This API is more efficient but potentially unsafe, so it is exposed as a separate function to make the lack of safety explicit.

An alternative would be to control validation via an additional argument, but this was not chosen for the above reason.

select ST_GeomFromWKB('0x01....', false); -- Skip validation via `false` arg

Implementation

The function kernel for ST_GeomFromWKBUnchecked() is already implemented, this PR only exposed such functionality through a new function, and add tests.


# TODO: Test error case after error message check is supported in `assert_query_result`
# Using invalid WKB elsewhere may result in undefined behavior.
# eng.assert_query_result("SELECT ST_AsText(ST_GeomFromWKBUnchecked(0x01))", None)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow-up PR perhaps: I found it's not possible to assert error message if the query fails.

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 sometimes we do:

with pytest.raises(lib.SedonaError, match="foofy"):
    eng.execute_and_collect("SELECT ...")

Would that work here? If not I think it is OK to skip this check for now.

/// Documentation for `ST_GeomFromWKBUnchecked()`.
///
/// Parameterized for reuse if `ST_GeogFromWKBUnchecked()` is implemented in the future.
fn doc_unchecked(name: &str, out_type_name: &str) -> Documentation {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question: Is it the case that SQL reference (e.g. https://sedona.apache.org/sedonadb/latest/reference/sql/#st_geomfromwkb) can be auto-generated through these doc() traits, but we still have to update them manually?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's currently being updated manually. It is also in a state of flux right now where we're trying to separate the pages from each other in a way that each page can have a bit more detail, but still generate the main page. For now having the doc reference like you did here is perfect.

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!

One suggestion on the Python test (either remove the todo or use pytest.raises() if that works) but other than that it looks great!


# TODO: Test error case after error message check is supported in `assert_query_result`
# Using invalid WKB elsewhere may result in undefined behavior.
# eng.assert_query_result("SELECT ST_AsText(ST_GeomFromWKBUnchecked(0x01))", 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 sometimes we do:

with pytest.raises(lib.SedonaError, match="foofy"):
    eng.execute_and_collect("SELECT ...")

Would that work here? If not I think it is OK to skip this check for now.

/// Documentation for `ST_GeomFromWKBUnchecked()`.
///
/// Parameterized for reuse if `ST_GeogFromWKBUnchecked()` is implemented in the future.
fn doc_unchecked(name: &str, out_type_name: &str) -> Documentation {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's currently being updated manually. It is also in a state of flux right now where we're trying to separate the pages from each other in a way that each page can have a bit more detail, but still generate the main page. For now having the doc reference like you did here is perfect.

@2010YOUY01
Copy link
Contributor Author

Thank you for the review.

I think sometimes we do:

with pytest.raises(lib.SedonaError, match="foofy"):
    eng.execute_and_collect("SELECT ...")

Would that work here? If not I think it is OK to skip this check for now.

Yes it works, applied in 3524859

I was thinking wrapping such raises syntax with something like

eng.assert_query_error("select foo()", Exception, "Function did not exist")

To make error assertion slightly more ergonomic, should we do this as follow up?

@2010YOUY01
Copy link
Contributor Author

CI python test failed in https://github.com/apache/sedona-db/actions/runs/21236733252/job/61106200223?pr=533

Looks like it's not related to the change, and I can't reproduce it locally with repeated test runs. Let me re-trigger CI to see if it is reproducible.

@2010YOUY01 2010YOUY01 closed this Jan 22, 2026
@2010YOUY01 2010YOUY01 reopened this Jan 22, 2026
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!

I believe the CI failure is due to pandas 3.0 (released today).

@paleolimbot paleolimbot merged commit 7ea6f49 into apache:main Jan 22, 2026
28 of 30 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.

2 participants