diff --git a/NEWS.md b/NEWS.md index 9eed3d701..8a9ac5eee 100644 --- a/NEWS.md +++ b/NEWS.md @@ -50,6 +50,7 @@ - New method `$dt$time()` to extract the time from a `datetime` variable (#428). - New method `pl$read_parquet()` that is a shortcut for `pl$scan_parquet()$collect()` (#434). - Rename `$str$str_explode()` to `$str$explode()` (#436). +- New argument `eager` of `LazyFrame$set_optimization_toggle()` (#439). # polars 0.8.1 diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index a107ca392..6276af617 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -1055,7 +1055,7 @@ LazyFrame$schema <- function() .Call(wrap__LazyFrame__schema, self) LazyFrame$fetch <- function(n_rows) .Call(wrap__LazyFrame__fetch, self, n_rows) -LazyFrame$set_optimization_toggle <- function(type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming) .Call(wrap__LazyFrame__set_optimization_toggle, self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming) +LazyFrame$set_optimization_toggle <- function(type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) .Call(wrap__LazyFrame__set_optimization_toggle, self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, streaming, eager) LazyFrame$get_optimization_toggle <- function() .Call(wrap__LazyFrame__get_optimization_toggle, self) diff --git a/R/lazyframe__lazy.R b/R/lazyframe__lazy.R index 097fc4f3b..5a3d856f7 100644 --- a/R/lazyframe__lazy.R +++ b/R/lazyframe__lazy.R @@ -306,6 +306,7 @@ LazyFrame_get_optimization_toggle = function() { #' reused. #' @param streaming Boolean. Run parts of the query in a streaming fashion #' (this is in an alpha state). +#' @param eager Boolean. Run the query eagerly. #' @return LazyFrame with specified optimization toggles #' @examples #' pl$LazyFrame(mtcars)$set_optimization_toggle(type_coercion = FALSE) @@ -317,7 +318,8 @@ LazyFrame_set_optimization_toggle = function( slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, - streaming = FALSE) { + streaming = FALSE, + eager = FALSE) { self |> .pr$LazyFrame$set_optimization_toggle( type_coercion, @@ -327,7 +329,8 @@ LazyFrame_set_optimization_toggle = function( slice_pushdown, comm_subplan_elim, comm_subexpr_elim, - streaming + streaming, + eager ) } diff --git a/man/LazyFrame_set_optimization_toggle.Rd b/man/LazyFrame_set_optimization_toggle.Rd index d1d3db90e..f83f5eba7 100644 --- a/man/LazyFrame_set_optimization_toggle.Rd +++ b/man/LazyFrame_set_optimization_toggle.Rd @@ -12,7 +12,8 @@ LazyFrame_set_optimization_toggle( slice_pushdown = TRUE, comm_subplan_elim = TRUE, comm_subexpr_elim = TRUE, - streaming = FALSE + streaming = FALSE, + eager = FALSE ) } \arguments{ @@ -39,6 +40,8 @@ reused.} \item{streaming}{Boolean. Run parts of the query in a streaming fashion (this is in an alpha state).} + +\item{eager}{Boolean. Run the query eagerly.} } \value{ LazyFrame with specified optimization toggles diff --git a/src/rust/src/lazy/dataframe.rs b/src/rust/src/lazy/dataframe.rs index f219d4a87..eba494d53 100644 --- a/src/rust/src/lazy/dataframe.rs +++ b/src/rust/src/lazy/dataframe.rs @@ -510,6 +510,8 @@ impl LazyFrame { comm_subplan_elim: Robj, comm_subexpr_elim: Robj, streaming: Robj, + // fast_projection: Robj, // There is no method like with_fast_projection + eager: Robj, ) -> RResult { let ldf = self .0 @@ -519,6 +521,7 @@ impl LazyFrame { .with_simplify_expr(robj_to!(bool, simplify_expression)?) .with_slice_pushdown(robj_to!(bool, slice_pushdown)?) .with_streaming(robj_to!(bool, streaming)?) + ._with_eager(robj_to!(bool, eager)?) .with_projection_pushdown(robj_to!(bool, projection_pushdown)?) .with_comm_subplan_elim(robj_to!(bool, comm_subplan_elim)?) .with_comm_subexpr_elim(robj_to!(bool, comm_subexpr_elim)?); @@ -549,6 +552,7 @@ impl LazyFrame { comm_subplan_elim = comm_subplan_elim, comm_subexpr_elim = comm_subexpr_elim, streaming = streaming, + eager = eager, ) } diff --git a/tests/testthat/test-lazy.R b/tests/testthat/test-lazy.R index b976162cf..c13a1cbbc 100644 --- a/tests/testthat/test-lazy.R +++ b/tests/testthat/test-lazy.R @@ -805,7 +805,8 @@ test_that("opt_toggles", { slice_pushdown = FALSE, comm_subplan_elim = FALSE, comm_subexpr_elim = FALSE, - streaming = TRUE + streaming = TRUE, + eager = TRUE ) opt_settings2 = lapply(opt_settings, `!`)