feat: differentiate dyn_display and dyn_debug for extension types#262
Open
thomaschi78 wants to merge 3 commits into
Open
feat: differentiate dyn_display and dyn_debug for extension types#262thomaschi78 wants to merge 3 commits into
thomaschi78 wants to merge 3 commits into
Conversation
Store `Result<T, String>` instead of `T` in each GeoArrow wrapper type so that an incompatible storage type passed to `GeoArrowExtensionTypeFactory` is captured as an error rather than causing a panic. The `invalid()` constructor and `TryFrom` conversion surface the error to callers; `name()` always returns the correct constant regardless of validity. Replaces the infallible `From<WrapperType> for geoarrow_schema::T` with `TryFrom`, extracts a shared `format_inner` helper in the macro to avoid duplicating `dyn_display`/`dyn_debug` logic, and adds 22 tests covering the valid and error paths across constructors, traits, and the factory.
…la-rs#259) dyn_display now produces a short lowercase string following Polars convention (e.g. point[xy, separated], geometry[interleaved], box[xyzm], wkb) via a ShortDisplay trait implemented for each geoarrow_schema type. dyn_debug keeps the verbose {:#?} output (e.g. PointType { coord_type: Separated, dim: XY, metadata: ... }) which is more useful for debugging. Adds 8 new tests pinning the exact display format for point, geometry, box, wkb, and wkt, and asserting that display and debug differ for valid types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #259.
What this changes
dyn_displayanddyn_debugpreviously produced identical output (both used{:?}). This PR differentiates them following the Polars convention documented inExtensionTypeImpl:dyn_display — new format
point[xy, separated],linestring[xyz, interleaved], …geometry[interleaved]box[xyzm]wkbwktInvalidExtensionType(<message>)dyn_debug — unchanged
Keeps
{:?}which produces the full derived Debug representation, e.g.:Implementation
ShortDisplaytrait with ashort_display() -> Stringmethod.impl_short_display_dim_coord!handles the 7 types that have bothdimension()andcoord_type().GeometryType,BoxType,WkbType,WktType) are implemented individually.format_inner(shared helper from Allow extension types to be fallible #260) is removed;dyn_displayanddyn_debugnow have distinct match arms.dyn_display != dyn_debugfor valid types.