You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
We are trying to implement more generic "scalar" kernels -- see discussion on #984
If one wants to call eq_scalar on a PrimtiveArray,
In this case, since the data type (Int8Type ) is an associated type of the PrimitiveArray type, Rust can infer the correct type for argument 2 into the 2i8 needed for calling eq_scalar.
However as soon as you have an ArrayRef (aka dynamic array), it becomes challenging. To write a generic "compare this array to a scalar value" we would liek to write something like this:
/// Perform `left == right` operation on an array and a numeric scalar/// value. Supports PrimtiveArrays, and DictionaryArrays that have primitive valuespubfneq_dyn_scalar<T>(left:&dynArray,right:T::Native,) -> Result<BooleanArray>whereT:ArrowNumericType,{
...}
However, to actually call this function, the type of right needs to match T, but there is a potentially infinite number of concrete T types that could have a matching associated type Native, as explained by @shepmaster in #984 (comment)
Practically that means that all calls to eq_dyn_scalar would require type annotations which matched the values of the array, which largely defeats the purpose of eq_dyn_scalar
let array = builder.finish();// still need the UInt8Type annotationslet a_eq = eq_dyn_scalar::<UInt8Type>(&array,123u8).unwrap();assert_eq!(
a_eq,
BooleanArray::from(vec![Some(true), None, Some(false)]));
Describe the solution you'd like
So the proposal from @shepmaster at #984 (comment) is to add a trait that maps in the reverse direction, so we could have something like:
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
We are trying to implement more generic "scalar" kernels -- see discussion on #984
If one wants to call
eq_scalar
on aPrimtiveArray
,In this case, since the data type (
Int8Type
) is an associated type of thePrimitiveArray
type, Rust can infer the correct type for argument2
into the2i8
needed for calling eq_scalar.However as soon as you have an
ArrayRef
(aka dynamic array), it becomes challenging. To write a generic "compare this array to a scalar value" we would liek to write something like this:However, to actually call this function, the type of
right
needs to matchT
, but there is a potentially infinite number of concrete T types that could have a matching associated typeNative
, as explained by @shepmaster in #984 (comment)Practically that means that all calls to
eq_dyn_scalar
would require type annotations which matched the values of the array, which largely defeats the purpose ofeq_dyn_scalar
Describe the solution you'd like
So the proposal from @shepmaster at #984 (comment) is to add a trait that maps in the reverse direction, so we could have something like:
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: