From 006769aba09f35cc6da503a2830269bd0f75c559 Mon Sep 17 00:00:00 2001 From: alexander-beedie Date: Sun, 6 Oct 2024 14:47:21 +0400 Subject: [PATCH] bitwise feature flag --- crates/polars-sql/Cargo.toml | 4 ++-- crates/polars-sql/src/functions.rs | 3 +++ crates/polars/Cargo.toml | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/polars-sql/Cargo.toml b/crates/polars-sql/Cargo.toml index ebc211e8d8936..b5b875403b6d9 100644 --- a/crates/polars-sql/Cargo.toml +++ b/crates/polars-sql/Cargo.toml @@ -10,7 +10,7 @@ description = "SQL transpiler for Polars. Converts SQL to Polars logical plans" [dependencies] arrow = { workspace = true } -polars-core = { workspace = true, features = ["bitwise", "rows"] } +polars-core = { workspace = true, features = ["rows"] } polars-error = { workspace = true } polars-lazy = { workspace = true, features = ["abs", "binary_encoding", "concat_str", "cross_join", "cum_agg", "dtype-date", "dtype-decimal", "dtype-struct", "is_in", "list_eval", "log", "meta", "regex", "round_series", "sign", "string_reverse", "strings", "timezones", "trigonometry"] } polars-ops = { workspace = true } @@ -24,7 +24,6 @@ rand = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } sqlparser = { workspace = true } -# sqlparser = { git = "https://github.com/sqlparser-rs/sqlparser-rs.git", rev = "ae3b5844c839072c235965fe0d1bddc473dced87" } [dev-dependencies] # to display dataframes in case of test failures @@ -34,6 +33,7 @@ polars-core = { workspace = true, features = ["fmt"] } default = [] nightly = [] binary_encoding = ["polars-lazy/binary_encoding"] +bitwise = ["polars-lazy/bitwise"] csv = ["polars-lazy/csv"] diagonal_concat = ["polars-lazy/diagonal_concat"] dtype-decimal = ["polars-lazy/dtype-decimal"] diff --git a/crates/polars-sql/src/functions.rs b/crates/polars-sql/src/functions.rs index 94293fc1db8c3..ed845079acec7 100644 --- a/crates/polars-sql/src/functions.rs +++ b/crates/polars-sql/src/functions.rs @@ -42,6 +42,7 @@ pub(crate) enum PolarsSQLFunctions { /// ```sql /// SELECT BIT_COUNT(column_1) FROM df; /// ``` + #[cfg(feature = "bitwise")] BitCount, /// SQL 'bit_or' function. /// Returns the bitwise OR of the input expressions. @@ -754,6 +755,7 @@ impl PolarsSQLFunctions { // Bitwise functions // ---- "bit_and" | "bitand" => Self::BitAnd, + #[cfg(feature = "bitwise")] "bit_count" | "bitcount" => Self::BitCount, "bit_or" | "bitor" => Self::BitOr, "bit_xor" | "bitxor" | "xor" => Self::BitXor, @@ -913,6 +915,7 @@ impl SQLFunctionVisitor<'_> { // Bitwise functions // ---- BitAnd => self.visit_binary::(Expr::and), + #[cfg(feature = "bitwise")] BitCount => self.visit_unary(Expr::bitwise_count_ones), BitOr => self.visit_binary::(Expr::or), BitXor => self.visit_binary::(Expr::xor), diff --git a/crates/polars/Cargo.toml b/crates/polars/Cargo.toml index 31bae99c61466..4e796e782a573 100644 --- a/crates/polars/Cargo.toml +++ b/crates/polars/Cargo.toml @@ -132,7 +132,13 @@ array_any_all = ["polars-lazy?/array_any_all", "dtype-array"] asof_join = ["polars-lazy?/asof_join", "polars-ops/asof_join"] iejoin = ["polars-lazy?/iejoin"] binary_encoding = ["polars-ops/binary_encoding", "polars-lazy?/binary_encoding", "polars-sql?/binary_encoding"] -bitwise = ["polars-core/bitwise", "polars-plan?/bitwise", "polars-ops/bitwise", "polars-lazy?/bitwise"] +bitwise = [ + "polars-core/bitwise", + "polars-plan?/bitwise", + "polars-ops/bitwise", + "polars-lazy?/bitwise", + "polars-sql?/bitwise", +] business = ["polars-lazy?/business", "polars-ops/business"] checked_arithmetic = ["polars-core/checked_arithmetic"] chunked_ids = ["polars-ops?/chunked_ids"]