-
Notifications
You must be signed in to change notification settings - Fork 36
Implement ST_InteriorRingN #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
paleolimbot
left a comment
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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:
sedona-db/rust/sedona-functions/src/st_reverse.rs
Lines 189 to 190 in 16d232b
| 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
There was a problem hiding this comment.
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 👍
| let input_wkt = create_array( | ||
| &[ | ||
| // I. Null/Empty/Non-Polygon Inputs |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
| benchmark::scalar( | ||
| c, | ||
| &f, | ||
| "native", | ||
| "st_interiorringn", | ||
| BenchmarkArgs::ArrayArray(Polygon(10), Int64(1, 10)), | ||
| ); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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:
sedona-db/rust/sedona-testing/src/benchmark_util.rs
Lines 275 to 276 in 16d232b
| /// Randomly generated polygon input with a specified number of vertices | |
| Polygon(usize), |
...and it would need to be added to build_geometry():
sedona-db/rust/sedona-testing/src/benchmark_util.rs
Lines 421 to 429 in 16d232b
| 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)
paleolimbot
left a comment
There was a problem hiding this 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)
| ("geom", "index", "expected"), | ||
| [ | ||
| # I. Null/Empty/Non-Polygon Inputs |
There was a problem hiding this comment.
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?
paleolimbot
left a comment
There was a problem hiding this 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>, |
There was a problem hiding this comment.
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.
| # 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), |
There was a problem hiding this comment.
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
This PR implements
ST_InteriorRingNusinggeo-traitsas described in #224 And adds support forInt64inBenchmarkArgs