use polars::prelude::{Column, DataFrame, PolarsResult};
#[cfg_attr(not(feature = "polars-egress"), allow(dead_code))]
pub(crate) fn df_from_columns(columns: Vec<Column>) -> PolarsResult<DataFrame> {
let mut cols = columns.into_iter();
let Some(first) = cols.next() else {
return Ok(DataFrame::default());
};
let mut df = first.into_frame();
for col in cols {
df.with_column(col)?;
}
Ok(df)
}
#[cfg(feature = "polars-egress")]
#[inline]
pub(crate) unsafe fn rs_array_into_pa(
rs: arrow::ffi::FFI_ArrowArray,
) -> polars_arrow::ffi::ArrowArray {
unsafe { std::mem::transmute::<arrow::ffi::FFI_ArrowArray, polars_arrow::ffi::ArrowArray>(rs) }
}
#[cfg(feature = "polars-egress")]
#[inline]
pub(crate) unsafe fn rs_schema_into_pa(
rs: arrow::ffi::FFI_ArrowSchema,
) -> polars_arrow::ffi::ArrowSchema {
unsafe {
std::mem::transmute::<arrow::ffi::FFI_ArrowSchema, polars_arrow::ffi::ArrowSchema>(rs)
}
}