scovich commented on code in PR #8438:
URL: https://github.com/apache/arrow-rs/pull/8438#discussion_r2377010985


##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -796,8 +778,17 @@ impl StructArrayBuilder {
 }
 
 /// returns the non-null element at index as a Variant
-fn typed_value_to_variant(typed_value: &ArrayRef, index: usize) -> Variant<'_, 
'_> {
-    match typed_value.data_type() {
+fn typed_value_to_variant<'a>(
+    typed_value: &'a ArrayRef,
+    value: Option<&BinaryViewArray>,
+    index: usize,
+) -> Variant<'a, 'a> {
+    let data_type = typed_value.data_type();
+    if value.is_some_and(|v| !matches!(data_type, DataType::Struct(_)) && 
v.is_valid(index)) {
+        // Only a partially shredded struct is allowed to have values for both 
columns
+        panic!("Invalid variant, conflicting value and typed_value");

Review Comment:
   So this one is a row-oriented check, unlike the columnar type checks I added 
in `rewrite_to_view_types`:
   
   For a specific row, both `value` and `typed_value` were non-NULL and 
`typed_value` is not a struct. I suppose we could try to memoize the "not a 
struct" part in order to avoid the overhead of that `matches!` invocation, but 
(a) checking for a specific enum variant is really cheap; and (b) where would 
we store the answer, given that we don't build any kind of a tree?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to