sdf-jkl commented on code in PR #10810:
URL: https://github.com/apache/arrow-rs/pull/10810#discussion_r3867013310
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -285,18 +328,14 @@ impl VariantArray {
/// # Requirements of the `StructArray`
///
/// 1. A required field named `metadata` which is binary, large_binary, or
- /// binary_view
+ /// binary_view, optionally dictionary- or run-end-encoded
Review Comment:
I thought this one makes sense as both are compound adjectives:
`dictionary-encoded` and `run-end-encoded`
##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -1429,8 +1476,70 @@ mod test {
let err = VariantArray::try_new(&array);
assert_eq!(
err.unwrap_err().to_string(),
- "Invalid argument error: VariantArray 'metadata' field must be
Binary, LargeBinary, or BinaryView, got Int32"
+ "Invalid argument error: VariantArray 'metadata' field must be
Binary, LargeBinary, BinaryView, or a Dictionary or RunEndEncoded array of one
of those types, got Int32"
+ );
+ }
+
+ #[test]
+ fn encoded_metadata_supports_nulls_slices_and_variant_get() {
+ let json: ArrayRef = Arc::new(StringArray::from(vec![
+ Some(r#"{"a":0}"#),
+ Some(r#"{"a":1}"#),
+ None,
+ Some(r#"{"b":3}"#),
+ Some(r#"{"b":4}"#),
+ ]));
+ let baseline = json_to_variant(&json).unwrap();
+ let metadata = baseline.metadata_column().as_binary_view();
+ let metadata_a = metadata.value(0);
+ let metadata_b = metadata.value(3);
+
+ let dictionary_values: ArrayRef =
Arc::new(BinaryArray::from(vec![metadata_a, metadata_b]));
Review Comment:
nit: Could reuse dedicated builders for both manual constructions:
```rust
let logical_metadata = [
Some(metadata_a),
Some(metadata_a),
None,
Some(metadata_b),
Some(metadata_b),
];
let mut dictionary =
BinaryDictionaryBuilder::<Int8Type>::new();
dictionary.extend(logical_metadata);
let dictionary: ArrayRef = Arc::new(dictionary.finish());
let mut ree = BinaryRunBuilder::<Int16Type>::new();
ree.extend(logical_metadata);
let run_end_encoded: ArrayRef = Arc::new(ree.finish());
```
--
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]