Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Consider the following:
fn foo() {
let mut b = VariantArrayBuilder::new(1);
b.append_null();
let v = b.build();
v.value(0); // will panic
}
Probing a VariantArray when that element is null will result in a panic:
thread 'cast_to_variant::tests::foo' panicked at /Users/matthewkim/.cargo/git/checkouts/arrow-rs-583cca34693b79b8/760b7b6/parquet-variant/src/variant.rs:318:14:
Invalid variant metadata: InvalidArgumentError("Received empty bytes")
This seems like an odd pattern, as it's not clear exactly what a user should do when iterating or probing through a VariantArray
Describe the solution you'd like
We could have VariantArray::value(i: usize) return an Option<Variant<'a>>. This way, it's clear when it's None, that element is considered null. Note, this is different from Some(Variant::Null))
Additional context
This feature is motivated by datafusion-variant, a higher-level library that integrates with Datafusion through a series of udfs
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Consider the following:
Probing a
VariantArraywhen that element is null will result in a panic:This seems like an odd pattern, as it's not clear exactly what a user should do when iterating or probing through a
VariantArrayDescribe the solution you'd like
We could have
VariantArray::value(i: usize)return anOption<Variant<'a>>. This way, it's clear when it'sNone, that element is considerednull. Note, this is different fromSome(Variant::Null))Additional context
This feature is motivated by datafusion-variant, a higher-level library that integrates with Datafusion through a series of udfs