Skip to content

Commit

Permalink
feat: expose the eager option of set_optimization_toggle (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi authored Oct 23, 2023
1 parent 483d92c commit 655f46a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions R/lazyframe__lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -327,7 +329,8 @@ LazyFrame_set_optimization_toggle = function(
slice_pushdown,
comm_subplan_elim,
comm_subexpr_elim,
streaming
streaming,
eager
)
}

Expand Down
5 changes: 4 additions & 1 deletion man/LazyFrame_set_optimization_toggle.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/rust/src/lazy/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
let ldf = self
.0
Expand All @@ -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)?);
Expand Down Expand Up @@ -549,6 +552,7 @@ impl LazyFrame {
comm_subplan_elim = comm_subplan_elim,
comm_subexpr_elim = comm_subexpr_elim,
streaming = streaming,
eager = eager,
)
}

Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, `!`)

Expand Down

0 comments on commit 655f46a

Please sign in to comment.