You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "sdf-jkl (via GitHub)" <gi...@apache.org> on 2026/07/10 20:51:08 UTC
[PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
sdf-jkl opened a new pull request, #10318:
URL: https://github.com/apache/arrow-rs/pull/10318
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
-->
- Closes #10306.
# Rationale for this change
arrow-rs doesn't follow the Variant spec by making `value` field optional.
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
- Make `value` field mandatory for `VariantArray` and `ShreddingState`.
- Fix the related APIs and tests
- Some DRY thrown in there for tests
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are these changes tested?
- Yes, fixed the unit tests
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
If this PR claims a performance improvement, please include evidence such as benchmark results.
-->
# Are there any user-facing changes?
- Yes, `value` field is now mandatory for Variant
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "sdf-jkl (via GitHub)" <gi...@apache.org>.
sdf-jkl commented on code in PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#discussion_r3572037816
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -396,25 +416,22 @@ impl VariantArray {
/// Note: Does not do deep validation of the [`Variant`], so it is up to the
/// caller to ensure that the metadata and value were constructed correctly.
pub fn try_value(&self, index: usize) -> Result<Variant<'_, '_>> {
- match (self.typed_value_column(), self.value_column()) {
+ let value = self.value_column();
+ match self.typed_value_column() {
// Always prefer typed_value, if available
- (Some(typed_value), value) if typed_value.is_valid(index) => {
+ Some(typed_value) if typed_value.is_valid(index) => {
typed_value_to_variant(typed_value, value, index)
Review Comment:
:+1: https://github.com/apache/arrow-rs/pull/10318/commits/b6315272adf7bf2920418e185281e3e74b6f2e7c
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "sdf-jkl (via GitHub)" <gi...@apache.org>.
sdf-jkl commented on code in PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#discussion_r3571826776
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -316,16 +325,27 @@ impl VariantArray {
})
}
+ /// Construct a perfectly shredded `VariantArray`: every value is in
+ /// `typed_value` and the required `value` column is all-null.
+ #[cfg(test)]
+ pub(crate) fn perfectly_shredded(
Review Comment:
Valid, thanks
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -316,16 +325,27 @@ impl VariantArray {
})
}
+ /// Construct a perfectly shredded `VariantArray`: every value is in
+ /// `typed_value` and the required `value` column is all-null.
+ #[cfg(test)]
+ pub(crate) fn perfectly_shredded(
+ metadata: ArrayRef,
+ typed_value: ArrayRef,
+ nulls: Option<NullBuffer>,
+ ) -> Self {
+ let value = all_null_value_column(typed_value.len());
+ Self::from_parts(metadata, value, Some(typed_value), nulls)
+ }
+
pub(crate) fn from_parts(
metadata: ArrayRef,
- value: Option<ArrayRef>,
+ value: ArrayRef,
Review Comment:
I thought about it, but I think it makes it misleading for a user. Seeing optional `value` field may lead them to believe that it really is optional for a `VariantArray`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "scovich (via GitHub)" <gi...@apache.org>.
scovich commented on PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#issuecomment-4951779919
> @alamb @scovich @klion26 please take a look!
FYI, I'm out the rest of July and can't promise meaningful reviews during that time. So don't block on me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "sdf-jkl (via GitHub)" <gi...@apache.org>.
sdf-jkl commented on PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#issuecomment-5027606769
@alamb upon further inspection it seems like we never really allowed writing shredded `VariantArray` with an empty `value` field when _used correctly_.
`shred_variant` always returned a `value` field:
https://github.com/apache/arrow-rs/blob/a16c4584d1fd194d236c1757e92ebcb0837cb0f0/parquet-variant-compute/src/shred_variant.rs#L103-L107
`variant_get`/`try_new` would propagate whatever the `value` field was without checking.
So the only way to construct a new shredded `VariantArray` from scratch with the field omitted would be via `from_parts`.
----
Regardless, other readers are lenient (https://github.com/apache/parquet-format/pull/591#issuecomment-4939397357), so I think it's a good idea to support that - https://github.com/apache/arrow-rs/pull/10318/commits/2738018fe15afb47096ddd88800618c78d13cc3a
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "sdf-jkl (via GitHub)" <gi...@apache.org>.
sdf-jkl commented on PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#issuecomment-4970073327
@alamb please take a look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "klion26 (via GitHub)" <gi...@apache.org>.
klion26 commented on code in PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#discussion_r3570133037
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -316,16 +325,27 @@ impl VariantArray {
})
}
+ /// Construct a perfectly shredded `VariantArray`: every value is in
+ /// `typed_value` and the required `value` column is all-null.
+ #[cfg(test)]
+ pub(crate) fn perfectly_shredded(
+ metadata: ArrayRef,
+ typed_value: ArrayRef,
+ nulls: Option<NullBuffer>,
+ ) -> Self {
+ let value = all_null_value_column(typed_value.len());
+ Self::from_parts(metadata, value, Some(typed_value), nulls)
+ }
+
pub(crate) fn from_parts(
metadata: ArrayRef,
- value: Option<ArrayRef>,
+ value: ArrayRef,
Review Comment:
What if we still keep the func signature, but `None` means perfect shredding? so that the caller doesn't need to construct the all empty value column
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -396,25 +416,22 @@ impl VariantArray {
/// Note: Does not do deep validation of the [`Variant`], so it is up to the
/// caller to ensure that the metadata and value were constructed correctly.
pub fn try_value(&self, index: usize) -> Result<Variant<'_, '_>> {
- match (self.typed_value_column(), self.value_column()) {
+ let value = self.value_column();
+ match self.typed_value_column() {
// Always prefer typed_value, if available
- (Some(typed_value), value) if typed_value.is_valid(index) => {
+ Some(typed_value) if typed_value.is_valid(index) => {
typed_value_to_variant(typed_value, value, index)
Review Comment:
Will moving the check in `typed_value_to_variant` here be better? so that we don't need to pass the `value` column when calling`typed_value_to_variant`, the fun name seems to be for `typed_value` but we still need to pass the `value` in
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -316,16 +325,27 @@ impl VariantArray {
})
}
+ /// Construct a perfectly shredded `VariantArray`: every value is in
+ /// `typed_value` and the required `value` column is all-null.
+ #[cfg(test)]
+ pub(crate) fn perfectly_shredded(
Review Comment:
Seems this is for better construct test cases, not sure if this is the right place to put it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "sdf-jkl (via GitHub)" <gi...@apache.org>.
sdf-jkl commented on PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#issuecomment-4939548359
@alamb @scovich @klion26 please take a look!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Variant] make `value` mandatory field for `VariantArray`/`ShreddingState` [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10318:
URL: https://github.com/apache/arrow-rs/pull/10318#discussion_r3605820896
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -316,16 +325,27 @@ impl VariantArray {
})
}
+ /// Construct a perfectly shredded `VariantArray`: every value is in
+ /// `typed_value` and the required `value` column is all-null.
+ #[cfg(test)]
+ pub(crate) fn perfectly_shredded(
+ metadata: ArrayRef,
+ typed_value: ArrayRef,
+ nulls: Option<NullBuffer>,
+ ) -> Self {
+ let value = all_null_value_column(typed_value.len());
+ Self::from_parts(metadata, value, Some(typed_value), nulls)
+ }
+
pub(crate) fn from_parts(
metadata: ArrayRef,
- value: Option<ArrayRef>,
+ value: ArrayRef,
Review Comment:
since this is pub crate I think it fine (and not a public API)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org