Skip to content

Commit

Permalink
add 'list_eval' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Jan 14, 2024
1 parent 467c6f7 commit 619de08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion crates/polars-sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description = "SQL transpiler for Polars. Converts SQL to Polars logical plans"
arrow = { workspace = true }
polars-core = { workspace = true }
polars-error = { workspace = true }
polars-lazy = { workspace = true, features = ["abs", "binary_encoding", "concat_str", "cross_join", "cum_agg", "dtype-date", "is_in", "log", "meta", "regex", "round_series", "sign", "string_reverse", "strings", "trigonometry"] }
polars-lazy = { workspace = true, features = ["abs", "binary_encoding", "concat_str", "cross_join", "cum_agg", "dtype-date", "is_in", "list_eval", "log", "meta", "regex", "round_series", "sign", "string_reverse", "strings", "trigonometry"] }
polars-plan = { workspace = true }

hex = { workspace = true }
Expand All @@ -35,4 +35,5 @@ parquet = ["polars-lazy/parquet"]
semi_anti_join = ["polars-lazy/semi_anti_join"]
diagonal_concat = ["polars-lazy/diagonal_concat"]
binary_encoding = ["polars-lazy/binary_encoding"]
list_eval = ["polars-lazy/list_eval"]
nightly = []
5 changes: 4 additions & 1 deletion crates/polars-sql/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use polars_core::prelude::{polars_bail, polars_err, PolarsResult};
use polars_lazy::dsl::{Expr, ListNameSpaceExtension};
use polars_lazy::dsl::Expr;
#[cfg(feature = "list_eval")]
use polars_lazy::dsl::ListNameSpaceExtension;
use polars_plan::dsl::{coalesce, concat_str, count, when};
use polars_plan::logical_plan::LiteralValue;
use polars_plan::prelude::LiteralValue::Null;
Expand Down Expand Up @@ -972,6 +974,7 @@ impl SQLFunctionVisitor<'_> {
ArraySum => self.visit_unary(|e| e.list().sum()),
ArrayToString => match function.args.len() {
2 => self.try_visit_binary(|e, sep| { Ok(e.list().join(sep, true)) }),
#[cfg(feature = "list_eval")]
3 => self.try_visit_ternary(|e, sep, null_value| {
match null_value {
Expr::Literal(LiteralValue::String(v)) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ regex = ["polars-lazy?/regex"]
list_any_all = ["polars-lazy?/list_any_all"]
list_count = ["polars-ops/list_count", "polars-lazy?/list_count"]
list_drop_nulls = ["polars-lazy?/list_drop_nulls"]
list_eval = ["polars-lazy?/list_eval"]
list_eval = ["polars-lazy?/list_eval", "polars-sql?/list_eval"]
list_gather = ["polars-ops/list_gather", "polars-lazy?/list_gather"]
list_sample = ["polars-lazy?/list_sample"]
list_sets = ["polars-lazy?/list_sets"]
Expand Down

0 comments on commit 619de08

Please sign in to comment.