Skip to content

Conversation

@Abeeujah
Copy link
Contributor

This PR implements ST_InteriorRingN using geo-traits as described in #224 And adds support for Int64 in BenchmarkArgs

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 should be fixed by #382 and isn't related to this PR.

_ => None,
};

if let Some(buf) = geometry {
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 the writing of the output should be more like the output writing you added for ST_Reverse:

coords.rev().try_for_each(|coord| {
write_wkb_coord_trait(writer, &coord).map_err(|e| DataFusionError::Execution(e.to_string()))

...in particular, I am not sure that to_line_string() and x_y() are what we want here because we need to support Z, M, and ZM coordinate types.

Also, wkb might be a better name than buf here since I don't think buf is actually a buffer here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

polygon.interior() returns a LinearRing which is Wkb coded differently from Linestring, though the coords are the same, the test tends to fail since it returns a linear ring instead of a linestring, hence the reason for the to_linestring() there.

Would update the logic there. 👍 and use write_wkb_coord_trait instead 👍

Comment on lines 150 to 152
let input_wkt = create_array(
&[
// I. Null/Empty/Non-Polygon Inputs
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!

I think the missing cases here are Z, M, and ZM. It may be helpful to break these up into a few related input_wkt/inters/expected triplets to keep the whole test case roughly on your screen as you're scrolling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would add them, and separate into groups 👍

Comment on lines 85 to 91
benchmark::scalar(
c,
&f,
"native",
"st_interiorringn",
BenchmarkArgs::ArrayArray(Polygon(10), Int64(1, 10)),
);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is a very representative benchmark because it sould return NULL for every input (Polygon(10) doesn't have a hole). It may be less confusing to omit it here (rather than include a version that isn't measuring what it appears to be measuring).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a way to guage and know which would have a hole? say Polygon(500)?

Copy link
Member

Choose a reason for hiding this comment

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

We'd need a new BenchmarkArgSpec (maybe PolygonWithHole) here:

/// Randomly generated polygon input with a specified number of vertices
Polygon(usize),

...and it would need to be added to build_geometry():

fn build_geometry(
&self,
i: usize,
geom_type: GeometryTypeId,
num_batches: usize,
vertex_count: usize,
num_parts_count: usize,
rows_per_batch: usize,
) -> Result<Vec<ArrayRef>> {

(the polygon hole rate is something you can specify to the random partitioned data builder)

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.

This is looking great! Feel free to punt on the benchmark data suggestion (but if you do, perhaps remove the benchmark so that we don't leave a misleading one in)

Comment on lines +1183 to +1185
("geom", "index", "expected"),
[
# I. Null/Empty/Non-Polygon Inputs
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the Z, M, and ZM cases you generated below to this list as well?

@Abeeujah Abeeujah requested a review from paleolimbot November 28, 2025 22:39
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.

Thanks!

There's one clippy error we need to fix to keep CI happy (I put a suggestion inline).

vertex_count: usize,
num_parts_count: usize,
rows_per_batch: usize,
polygon_hole_rate: Option<f64>,
Copy link
Member

Choose a reason for hiding this comment

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

This caused clippy to complain about too many arguments. While clippy is right here (the call to build_geometry is getting a bit unwieldy/unreadable), it's an internal function and it's well tested. You can add #[allow(clippy::too_many_arguments)] right above fn build_geometry( to fix the error.

Comment on lines +1207 to +1208
# Invalid index n=0 (Assuming 1-based indexing means n=0 is invalid/out of range)
("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 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.

Testing a negative index case would be nice

@paleolimbot paleolimbot merged commit 689da4f into apache:main Dec 1, 2025
14 checks passed
pwrliang pushed a commit to pwrliang/sedona-db that referenced this pull request Dec 6, 2025
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.

3 participants