Conversation
|
Are you able to just add these constraints where necessary? This would avoid making a breaking change |
Hmm, but the |
|
You can add constraints for marker traits at point of usage |
|
Sorry, I still don't know how can I add I can let the function return |
|
I'm confused, Perhaps you could provide a small code reproducer? |
Hmm, do you mean to return Because |
|
|
|
I just tried it. Looks like it works.
Interesting. So even fn get_arrow_datum(datum: &Datum) -> Result<Box<dyn ArrowDatum + Send>> {
match datum.literal() {
PrimitiveLiteral::Boolean(value) => Ok(Box::new(BooleanArray::new_scalar(*value))),
PrimitiveLiteral::Int(value) => Ok(Box::new(Int32Array::new_scalar(*value))),
PrimitiveLiteral::Long(value) => Ok(Box::new(Int64Array::new_scalar(*value))),
PrimitiveLiteral::Float(value) => Ok(Box::new(Float32Array::new_scalar(value.as_f32()))),
PrimitiveLiteral::Double(value) => Ok(Box::new(Float64Array::new_scalar(value.as_f64()))),
l => Err(Error::new(
ErrorKind::DataInvalid,
format!("Unsupported literal type: {:?}", l),
)),
}
}
fn some_func(...) {
let literal = get_arrow_datum(&literal)?;
....
move |batch| {
let left = batch.column(term_index);
lt(left, literal.as_ref())
},
....
} |
Ah, got it. I thought it needs to explicitly implement it. Learn it. Thank you @tustvold ! |
Which issue does this PR close?
Closes #.
Rationale for this change
While working on apache/iceberg-rust#295, I faced an issue that a
Datum(it is aScalarbehind the trait) cannot be moved into a closure.Because the function to return
Datummay returnResultto propagate error, I cannot put it into the closure.I'm wondering if we can make
DatumalsoSend+Sync?What changes are included in this PR?
Are there any user-facing changes?