duckdb-rs
duckdb-rs copied to clipboard
`FromSql` is not implemented for `Vec<f64>`
Is there a way to get a Vec from an array column?
I think you can decode it as an Value::List: https://docs.rs/duckdb/latest/duckdb/types/enum.Value.html#variant.List
I think you can decode it as an
Value::List: https://docs.rs/duckdb/latest/duckdb/types/enum.Value.html#variant.List
Is there a way of doing this without having to iterate over Vec<Value> and convert each element into f64, thereby creating a copy of the vector? We've a situation where the vectors aren't small.
Extracting a List result calls from_list(), which just iterates over those values and calls .to_owned() on each one, as I think you're trying to avoid doing.
fn from_list(start: usize, end: usize, idx: usize, values: &ArrayRef) -> Value {
Value::List(
(start..end)
.map(|row| Row::value_ref_internal(row, idx, values).to_owned())
.collect(),
)
}
To put it in more general terms, if I understand how this all works, every result row is a bunch of ValueRefs, which are pointers to memory that duckdb (not duckdb-rs) owns. I would guess that this memory is freed when you finish iterating to the end of a chunk, so you'd better make a copy.