-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Send + Sync traits for Datum #5587
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 aScalar
behind the trait) cannot be moved into a closure.Because the function to return
Datum
may returnResult
to propagate error, I cannot put it into the closure.I'm wondering if we can make
Datum
alsoSend
+Sync
?What changes are included in this PR?
Are there any user-facing changes?