-
Notifications
You must be signed in to change notification settings - Fork 1k
[Variant] Introduce new BorrowedShreddingState concept #8499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CC @alamb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review
// 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now encapsulated by ShreddingState::try_from
} | ||
|
||
/// Returns a borrowed version of this shredding state | ||
pub fn borrow(&self) -> BorrowedShreddingState<'_> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had an impl From
instead, but this seems to be more readable/intuitive at call sites.
Should be a quickie, assuming reviewers agree with the premise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it -- thank you @scovich
self.typed_value.as_ref() | ||
} | ||
|
||
/// Returns a borrowed version of this shredding state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// 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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
I don't have much to add. FYI @codephage2020 @liamzwbao and @klion26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! Thanks, @scovich
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT, thanks for this work!
🚀 |
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_get
already suffers --ShreddingState
is inconvenient because it owns thevalue
andtyped_value
columns it refers to, even tho borrowing them usually suffices.What changes are included in this PR?
Define a new
BorrowedShreddingState
which 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
value
column is not a binary view.Are these changes tested?
Yes, existing tests cover this code.
Are there any user-facing changes?
New
TryFrom
andFrom
implementations.impl From<&StructArray> for ShreddingState
was replaced by a suitableTryFrom
.