Repository navigation
Error instead of silent Variant::Null for unimplemented typed_value types - #10598
Conversation
…ypes typed_value_to_variant's fallback arm was debug_assert!(false) + Ok(Variant::Null): release builds compile out the assert, so reading a row whose typed_value is valid but of an unimplemented type (e.g. an object-shredded Struct) silently misreported the stored value as null. Return ArrowError::NotYetImplemented instead — consistent across debug/release and within try_value's documented error contract. Closes apache#10597 Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Raghvendra Singh <[email protected]>
| // | ||
| // Returning Variant::Null here would silently misreport stored values | ||
| // as null in release builds (https://github.com/apache/arrow-rs/issues/10597) | ||
| _ => Err(ArrowError::NotYetImplemented(format!( |
There was a problem hiding this comment.
Still to implement: shredded objects (Struct) and shredded arrays (the List family) — both legal per the shredding spec, and reachable today since shred_variant itself produces them (the new test builds the Struct case that way). Truly-illegal types can't reach this arm: VariantArray::try_new already rejects them at construction via canonicalize_and_verify_data_type (Illegal shredded value type, InvalidArgumentError). So by the time typed_value_to_variant runs, the type is spec-legal and the only gap is the missing conversion — which is why NotYetImplemented seemed like the accurate classification. Implementing object/list here needs owned bytes (the borrowed Variant<'_, '_> return can't express an assembled object), so I left that for a follow-up.
There was a problem hiding this comment.
Checked the code here, the type(DataType::Struct) is valid here, it needs to be implemented.
There was a problem hiding this comment.
do we have an issue to link here? the comment above links to an issue already closed hence my confusion
There was a problem hiding this comment.
Yes — #10597 (linked in the description as "Closes #10597", and the new comment in this arm points there too). The #8091 link is the old code's — it goes away with the removed debug_assert block. #8091 was closed with the placeholder still in place, which is why #10597 was filed to track the remaining conversions (shredded objects/lists).
There was a problem hiding this comment.
@raghav-reglobe thanks for catching this. I think I was working on smth related to this earlier, but it was not documented in an issue.
This PR can close the bug of incorrectly returning Null for unsupported types. I will create a separate issue to track supporting composite types for typed_value_to_variant
sdf-jkl
left a comment
There was a problem hiding this comment.
@raghav-reglobe I have a suggestion for the error wording and a comment nit. Thanks for handling this
| // | ||
| // Returning Variant::Null here would silently misreport stored values | ||
| // as null in release builds (https://github.com/apache/arrow-rs/issues/10597) | ||
| _ => Err(ArrowError::NotYetImplemented(format!( | ||
| "VariantArray does not yet support typed_value type: {}", | ||
| typed_value.data_type() | ||
| ))), |
There was a problem hiding this comment.
These types being composite make try_value/value returning borrowed Variant for them painful.
We should leave a suggestion to unshred the array before extracting the value for now and decide if we want to proceed with this or defer.
| // | |
| // Returning Variant::Null here would silently misreport stored values | |
| // as null in release builds (https://github.com/apache/arrow-rs/issues/10597) | |
| _ => Err(ArrowError::NotYetImplemented(format!( | |
| "VariantArray does not yet support typed_value type: {}", | |
| typed_value.data_type() | |
| ))), | |
| // | |
| // Composite shredded values may require combining `value` and | |
| // `typed_value` and allocating new encoded bytes. `try_value` returns | |
| // borrowed Variant, so callers must unshred the array first. | |
| _ => Err(ArrowError::NotYetImplemented(format!( | |
| "VariantArray::try_value cannot materialize typed_value of type {} \ | |
| as a borrowed Variant; call unshred_variant first", | |
| typed_value.data_type() | |
| ))), |
There was a problem hiding this comment.
Applied in cfbe39a — your comment + error text verbatim (rustfmt reflowed the string continuation).
| // Returning Variant::Null here would silently misreport stored values | ||
| // as null in release builds (https://github.com/apache/arrow-rs/issues/10597) |
There was a problem hiding this comment.
We shouldn't add a timeline narrating comment about what used to be there.
| // | ||
| // Returning Variant::Null here would silently misreport stored values | ||
| // as null in release builds (https://github.com/apache/arrow-rs/issues/10597) | ||
| _ => Err(ArrowError::NotYetImplemented(format!( |
There was a problem hiding this comment.
@raghav-reglobe thanks for catching this. I think I was working on smth related to this earlier, but it was not documented in an issue.
This PR can close the bug of incorrectly returning Null for unsupported types. I will create a separate issue to track supporting composite types for typed_value_to_variant
…ry-narrating comment Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Raghvendra Singh <[email protected]>
Co-authored-by: Kosta Tarasov <[email protected]>
|
thanks @raghav-reglobe, @klion26 & @sdf-jkl |
…e` types (apache#10598) # Which issue does this PR close? - Closes apache#10597. # Rationale for this change `typed_value_to_variant`'s fallback arm for unimplemented `typed_value` types was `debug_assert!(false)` + `Ok(Variant::Null)`. Release builds compile out the assert, so reading a row whose `typed_value` is valid but of an unimplemented type (e.g. an object-shredded `Struct`) silently misreported the stored value as `Variant::Null` — data that exists reads as null with no signal, while the same read panics in debug builds. # What changes are included in this PR? - The fallback arm returns `ArrowError::NotYetImplemented` instead — consistent across debug/release, and within `try_value`'s documented error contract ("Errors if the data in `typed_value` cannot be interpreted as a valid `Variant`"). - A regression test pinning that an object-shredded `typed_value` errors rather than returning `Variant::Null`. Implementing the remaining conversions (objects/lists) is left for a follow-up — the borrowed `Variant<'_, '_>` return can't express an assembled object without owned bytes, so that is a larger change. # Are there any user-facing changes? `VariantArray::try_value` now returns an error (and `value` panics in release as it already did in debug) for unimplemented `typed_value` types, instead of silently returning `Variant::Null` in release builds. --------- Signed-off-by: Raghvendra Singh <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Kosta Tarasov <[email protected]>
Which issue does this PR close?
VariantArray::valuesilently returnsVariant::Nullfor unimplementedtyped_valuetypes in release builds #10597.Rationale for this change
typed_value_to_variant's fallback arm for unimplementedtyped_valuetypes wasdebug_assert!(false)+Ok(Variant::Null). Release builds compile out the assert, so reading a row whosetyped_valueis valid but of an unimplemented type (e.g. an object-shreddedStruct) silently misreported the stored value asVariant::Null— data that exists reads as null with no signal, while the same read panics in debug builds.What changes are included in this PR?
ArrowError::NotYetImplementedinstead — consistent across debug/release, and withintry_value's documented error contract ("Errors if the data intyped_valuecannot be interpreted as a validVariant").typed_valueerrors rather than returningVariant::Null.Implementing the remaining conversions (objects/lists) is left for a follow-up — the borrowed
Variant<'_, '_>return can't express an assembled object without owned bytes, so that is a larger change.Are there any user-facing changes?
VariantArray::try_valuenow returns an error (andvaluepanics in release as it already did in debug) for unimplementedtyped_valuetypes, instead of silently returningVariant::Nullin release builds.