-
Notifications
You must be signed in to change notification settings - Fork 839
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
A trait for append_value and append_null on ArrayBuilders #3644
Comments
As of the most recent arrow release, the builders implement |
So the builders implement extend but an &mut Builder does not have an implementation. I'm bashing my head against the wall trying to figure out how to make it work. here's the new method: pub fn set_val<T, R, V, F>(mut builder: T, value: Option<V>, getter: F) -> Result<()>
where
T: Extend<Option<R>>,
V: Deref<Target = Value>,
F: FnOnce(&V::Target) -> Option<R>,
{
let v = value
.as_deref()
.map(|v| {
getter(v).ok_or_else(|| {
let msg = format!("Could not cast {} to correct type", v);
Error::new(InvalidData, msg)
})
})
.transpose()?;
builder.extend(vec![v]);
Ok(())
} called as: DataType::Float64 => {
let b = struct_builder.field_builder::<Float64Builder>(i).unwrap();
set_val(b, value, Value::as_f64)?
} Yielding the error:
Am I missing something simple? If I try and reference
Is there a reason there can't be an implementation of Extend for &mut Builders? Thanks! |
Per conversation on discord I was missing an &mut T in the function's signature, extend should do what I need! |
I'm generating an arrow schema, and because there is not a macro, when it's time set the values I need to invoke a macro like this:
If there was a trait that contained append_value and append_null this macro could be replaced with a generic function, which would be a much better developer experience.
Thanks for the library!
The text was updated successfully, but these errors were encountered: