[Variant] Introduce new BorrowedShreddingState concept#8499
Merged
alamb merged 2 commits intoapache:mainfrom Sep 30, 2025
Merged
[Variant] Introduce new BorrowedShreddingState concept#8499alamb merged 2 commits intoapache:mainfrom
alamb merged 2 commits intoapache:mainfrom
Conversation
Contributor
Author
|
CC @alamb |
scovich
commented
Sep 29, 2025
Comment on lines
-275
to
-288
| // Extract value and typed_value fields | ||
| let value = if let Some(value_col) = inner.column_by_name("value") { | ||
| if let Some(binary_view) = value_col.as_binary_view_opt() { | ||
| Some(binary_view.clone()) | ||
| } else { | ||
| return Err(ArrowError::NotYetImplemented(format!( | ||
| "VariantArray 'value' field must be BinaryView, got {}", | ||
| value_col.data_type() | ||
| ))); | ||
| } | ||
| } else { | ||
| None | ||
| }; | ||
| let typed_value = inner.column_by_name("typed_value").cloned(); |
Contributor
Author
There was a problem hiding this comment.
Now encapsulated by ShreddingState::try_from
| } | ||
|
|
||
| /// Returns a borrowed version of this shredding state | ||
| pub fn borrow(&self) -> BorrowedShreddingState<'_> { |
Contributor
Author
There was a problem hiding this comment.
I originally had an impl From instead, but this seems to be more readable/intuitive at call sites.
Contributor
Author
|
Should be a quickie, assuming reviewers agree with the premise. |
alamb
approved these changes
Sep 29, 2025
| self.typed_value.as_ref() | ||
| } | ||
|
|
||
| /// Returns a borrowed version of this shredding state |
| // Peel away the prefix of path elements that traverses the shredded parts of this variant | ||
| // column. Shredding will traverse the rest of the path on a per-row basis. | ||
| let mut shredding_state = input.shredding_state().clone(); | ||
| let mut shredding_state = input.shredding_state().borrow(); |
Contributor
|
I don't have much to add. FYI @codephage2020 @liamzwbao and @klion26 |
Contributor
|
🚀 |
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.
Which issue does this PR close?
Struct#8336Rationale for this change
While pathfinding support for unshredding variant objects and arrays, I ran into the same issue that
variant_getalready suffers --ShreddingStateis inconvenient because it owns thevalueandtyped_valuecolumns it refers to, even tho borrowing them usually suffices.What changes are included in this PR?
Define a new
BorrowedShreddingStatewhich does what it says, and updateShreddedPathStep(in variant_get.rs) to use it.Also, make the constructor fallible in order to correctly report casting failures if the
valuecolumn is not a binary view.Are these changes tested?
Yes, existing tests cover this code.
Are there any user-facing changes?
New
TryFromandFromimplementations.impl From<&StructArray> for ShreddingStatewas replaced by a suitableTryFrom.