Closed
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Describe the solution you'd like
I want to build Scalar with ArrayRef, but I got an err
error[E0277]: the trait bound `std::sync::Arc<arrow_array::GenericListArray<i32>>: arrow_array::Array` is not satisfied
--> datafusion/common/src/scalar/mod.rs:3352:29
|
3352 | let s = Scalar::new(arr);
| ----------- ^^^ the trait `arrow_array::Array` is not implemented for `std::sync::Arc<arrow_array::GenericListArray<i32>>`
| |
| required by a bound introduced by this call
|
= help: the trait `arrow_array::Array` is implemented for `std::sync::Arc<(dyn arrow_array::Array + 'static)>`
note: required by a bound in `arrow_array::Scalar::<T>::new`
--> /Users/jayzhan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-array-50.0.0/src/scalar.rs:130:9
|
130 | impl<T: Array> Scalar<T> {
| ^^^^^ required by this bound in `Scalar::<T>::new`
...
136 | pub fn new(array: T) -> Self {
| --- required by a bound in this associated function
error[E0277]: the trait bound `std::sync::Arc<arrow_array::GenericListArray<i32>>: arrow_array::Array` is not satisfied
--> datafusion/common/src/scalar/mod.rs:3352:17
|
3352 | let s = Scalar::new(arr);
| ^^^^^^^^^^^^^^^^ the trait `arrow_array::Array` is not implemented for `std::sync::Arc<arrow_array::GenericListArray<i32>>`
|
= help: the trait `arrow_array::Array` is implemented for `std::sync::Arc<(dyn arrow_array::Array + 'static)>`
note: required by a bound in `arrow_array::Scalar`
--> /Users/jayzhan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-array-50.0.0/src/scalar.rs:128:22
|
128 | pub struct Scalar<T: Array>(T);
| ^^^^^ required by this bound in `Scalar`
error[E0277]: the trait bound `std::sync::Arc<arrow_array::GenericListArray<i32>>: arrow_array::Array` is not satisfied
--> datafusion/common/src/scalar/mod.rs:3353:26
|
3353 | println!("{:?}", s);
| ---- ^ the trait `arrow_array::Array` is not implemented for `std::sync::Arc<arrow_array::GenericListArray<i32>>`
| |
| required by a bound introduced by this call
|
= help: the trait `arrow_array::Array` is implemented for `std::sync::Arc<(dyn arrow_array::Array + 'static)>`
= note: required for `arrow_array::Scalar<std::sync::Arc<arrow_array::GenericListArray<i32>>>` to implement `Debug`
note: required by a bound in `core::fmt::rt::Argument::<'a>::new_debug`
--> /Users/jayzhan/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/fmt/rt.rs:100:29
|
100 | pub fn new_debug<'b, T: Debug>(x: &'b T) -> Argument<'_> {
| ^^^^^ required by this bound in `Argument::<'a>::new_debug`
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
This is what the code is like which we can also find in Scalar Example, but turns out not working
let arr = Arc::new(ListArray::from_iter_primitive::<Int32Type, _, _>(vec![
Some(vec![Some(1), None, Some(2)]),
]));
println!("{:?}", arr);
let s = Scalar::new(arr);
println!("{:?}", s);
I'm working on apache/datafusion#8846, and trying to find whether Scalar<Arc<ListArray>>
or Arc<Scalar<ListArray>>
is better.
however, the previous one meets the error described above, the second one we can only get &dyn Array
from fn get()
, which doesn't seem like a good way either.
Describe alternatives you've considered
Remove the example that is built with ArrayRef.
Additional context