-
Notifications
You must be signed in to change notification settings - Fork 5
Update cast_to_variant UDF to enhance variant handling and add new tests #21
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
Update cast_to_variant UDF to enhance variant handling and add new tests #21
Conversation
sdf-jkl
left a comment
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.
Everything looks great!
| fn from_array(_array: &ArrayRef) -> Result<ColumnarValue> { | ||
| todo!() | ||
| fn from_array(array: &ArrayRef) -> Result<ColumnarValue> { | ||
| // If the array is already a Variant array, pass it through unchanged |
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.
nice!
| ScalarValue::UInt64(i) => build_variant_array(i.as_ref().map(|i| *i)), | ||
|
|
||
| _ => todo!(), | ||
| if let ScalarValue::Struct(struct_array) = scalar_value |
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.
very clean.
|
|
||
| use super::*; | ||
|
|
||
| #[test] |
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.
tests look great!
Should we include other types in a next PR? (null, bool, decimal, timestamp/date/time, non-primitive ones like struct, list, map, union, dict, REE)
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.
Here's an issue to track test coverage in cast_to_variant
friendlymatthew
left a comment
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.
parts of #3
What changes in this pr?
Single-argument casts now delegate to parquet_variant_compute::cast_to_variant, so all Arrow types that kernel supports (strings/string views/large strings, fixed-size binary, numerics, temporal, lists/structs/maps/unions/etc.) work.
Existing Variant struct arrays are detected via VariantArray::try_new and passed through unchanged.
Two-argument metadata/value path kept as-is (binary-only).
Added return_field_from_args to emit a field with the VariantType extension and the canonical metadata/value struct shape.
New tests cover string arrays (StringArray, StringViewArray), fixed-size binary (16-byte), return-field extension tagging, plus prior scalar/array numeric and binary cases.