Skip to content

Error instead of silent Variant::Null for unimplemented typed_value types - #10598

Merged
Jefffrey merged 7 commits into
apache:mainfrom
raghav-reglobe:variant-value-unimplemented-error
Aug 14, 2026
Merged

Jefffrey merged 7 commits into
apache:mainfrom
raghav-reglobe:variant-value-unimplemented-error

Conversation

@raghav-reglobe

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

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.

…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]>
@github-actions github-actions Bot added the parquet-variant parquet-variant* crates label Aug 9, 2026
//
// 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!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be a nyi error or some other error type? as in are there still data types we need to implement or we've already implemented all and this truly is an unsupported datatype?

cc @sdf-jkl @klion26

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checked the code here, the type(DataType::Struct) is valid here, it needs to be implemented.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we have an issue to link here? the comment above links to an issue already closed hence my confusion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The issue - #10620

@sdf-jkl sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@raghav-reglobe I have a suggestion for the error wording and a comment nit. Thanks for handling this

Comment on lines +1155 to +1161
//
// 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()
))),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Suggested change
//
// 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()
))),

@raghav-reglobe raghav-reglobe Aug 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied in cfbe39a — your comment + error text verbatim (rustfmt reflowed the string continuation).

Comment on lines +1156 to +1157
// Returning Variant::Null here would silently misreport stored values
// as null in release builds (https://github.com/apache/arrow-rs/issues/10597)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't add a timeline narrating comment about what used to be there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in cfbe39a.

//
// 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!(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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 sdf-jkl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @raghav-reglobe LGTM

@Jefffrey Jefffrey added the bug Squash those bugs label Aug 14, 2026
@Jefffrey
Jefffrey merged commit 257f5f2 into apache:main Aug 14, 2026
19 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @raghav-reglobe, @klion26 & @sdf-jkl

MassivePizza pushed a commit to massive-com/arrow-rs that referenced this pull request Aug 19, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Squash those bugs parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] VariantArray::value silently returns Variant::Null for unimplemented typed_value types in release builds

4 participants