Skip to content

Commit

Permalink
add docs and actually create scalar columns
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite committed Sep 12, 2024
1 parent c0bb959 commit a6897fb
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 137 deletions.
2 changes: 2 additions & 0 deletions crates/polars-core/src/chunked_array/builder/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod binary_offset;
mod boolean;
#[cfg(feature = "dtype-array")]
pub mod fixed_size_list;
Expand All @@ -10,6 +11,7 @@ use std::sync::Arc;

use arrow::array::*;
use arrow::bitmap::Bitmap;
pub use binary_offset::*;
pub use boolean::*;
#[cfg(feature = "dtype-array")]
pub(crate) use fixed_size_list::*;
Expand Down
12 changes: 8 additions & 4 deletions crates/polars-core/src/datatypes/any_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ impl<'a> AnyValue<'a> {
Object(v) => ObjectOwned(OwnedObject(v.to_boxed())),
#[cfg(feature = "dtype-struct")]
Struct(idx, arr, fields) => {
let avs = struct_to_avs_static(idx, arr, fields);
let avs = struct_to_avs_static(idx, arr, fields)?;
StructOwned(Box::new((avs, fields.to_vec())))
},
#[cfg(feature = "dtype-struct")]
Expand Down Expand Up @@ -1222,7 +1222,11 @@ impl TotalEq for AnyValue<'_> {
}

#[cfg(feature = "dtype-struct")]
fn struct_to_avs_static(idx: usize, arr: &StructArray, fields: &[Field]) -> Vec<AnyValue<'static>> {
fn struct_to_avs_static(
idx: usize,
arr: &StructArray,
fields: &[Field],
) -> PolarsResult<Vec<AnyValue<'static>>> {
let arrs = arr.values();
let mut avs = Vec::with_capacity(arrs.len());
// amortize loop counter
Expand All @@ -1231,10 +1235,10 @@ fn struct_to_avs_static(idx: usize, arr: &StructArray, fields: &[Field]) -> Vec<
let arr = &**arrs.get_unchecked_release(i);
let field = fields.get_unchecked_release(i);
let av = arr_to_any_value(arr, idx, &field.dtype);
avs.push_unchecked(av.into_static().unwrap());
avs.push_unchecked(av.into_static()?);
}
}
avs
Ok(avs)
}

#[cfg(feature = "dtype-categorical")]
Expand Down
Loading

0 comments on commit a6897fb

Please sign in to comment.