Skip to content

Commit

Permalink
Lazy: add collect_all utility (#2371)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 14, 2022
1 parent 4233bc2 commit b4874c8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions polars/polars-lazy/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//!
use crate::prelude::*;
use polars_core::prelude::*;
use rayon::prelude::*;

/// Compute the covariance between two columns.
pub fn cov(a: Expr, b: Expr) -> Expr {
Expand Down Expand Up @@ -357,3 +358,13 @@ pub fn concat<L: AsRef<[LazyFrame]>>(inputs: L, rechunk: bool) -> Result<LazyFra
Ok(lf)
}
}

/// Collect all `LazyFrame` computations.
pub fn collect_all<I>(lfs: I) -> Result<Vec<DataFrame>>
where
I: IntoParallelIterator<Item = LazyFrame>,
{
let iter = lfs.into_par_iter();

polars_core::POOL.install(|| iter.map(|lf| lf.collect()).collect())
}

0 comments on commit b4874c8

Please sign in to comment.