Skip to content

Commit

Permalink
refactor(python): Expose group_by_dynamic in pyir (#19385)
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- authored Oct 23, 2024
1 parent fc8eec2 commit fe016ed
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 94 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/polars-arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ ahash = { workspace = true }
async-stream = { version = "0.3", optional = true }
tokio = { workspace = true, optional = true, features = ["io-util"] }

strum_macros = { workspace = true }

[dev-dependencies]
criterion = "0.5"
crossbeam-channel = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use num_traits::{Float, Num, NumCast};
pub use quantile::*;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;
pub use sum::*;
pub use variance::*;

Expand Down Expand Up @@ -69,8 +70,9 @@ where
Ok(Box::new(arr))
}

#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Hash, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum QuantileMethod {
#[default]
Nearest,
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-arrow/src/legacy/kernels/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use polars_error::PolarsResult;
use polars_error::{polars_bail, PolarsError};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;

pub enum Ambiguous {
Earliest,
Expand All @@ -32,8 +33,9 @@ impl FromStr for Ambiguous {
}
}

#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum NonExistent {
Null,
Raise,
Expand Down
1 change: 1 addition & 0 deletions crates/polars-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ regex = { workspace = true, optional = true }
# activate if you want serde support for Series and DataFrames
serde = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
strum_macros = { workspace = true }
thiserror = { workspace = true }
xxhash-rust = { workspace = true }

Expand Down
4 changes: 3 additions & 1 deletion crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use arrow::record_batch::RecordBatch;
use polars_utils::pl_str::PlSmallStr;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;

use crate::chunked_array::cast::CastOptions;
#[cfg(feature = "row_hash")]
Expand All @@ -49,8 +50,9 @@ pub enum NullStrategy {
Propagate,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Hash)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Hash, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum UniqueKeepStrategy {
/// Keep the first unique row.
First,
Expand Down
1 change: 1 addition & 0 deletions crates/polars-ops/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ regex = { workspace = true }
regex-syntax = { workspace = true }
serde = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
strum_macros = { workspace = true }
unicode-reverse = { workspace = true, optional = true }

[dependencies.jsonpath_lib]
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-ops/src/frame/join/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub type ChunkJoinIds = Vec<IdxSize>;
use polars_core::export::once_cell::sync::Lazy;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -108,8 +109,9 @@ impl JoinArgs {
}
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum JoinType {
Inner,
Left,
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-ops/src/series/ops/is_between.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use std::ops::BitAnd;
use polars_core::prelude::*;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;

#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum ClosedInterval {
#[default]
Both,
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-plan/src/dsl/function_expr/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt;
use std::sync::Arc;

use polars_core::prelude::*;
use strum_macros::IntoStaticStr;

use super::{ColumnsUdf, SpecialEq};
use crate::dsl::FieldsMapper;
Expand All @@ -21,7 +22,8 @@ pub enum BitwiseFunction {
}

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash)]
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash, IntoStaticStr)]
#[strum(serialize_all = "snake_case")]
pub enum BitwiseAggFunction {
And,
Or,
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-plan/src/dsl/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use polars_utils::pl_str::PlSmallStr;
use polars_utils::IdxSize;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;

use crate::dsl::Selector;

Expand Down Expand Up @@ -87,8 +88,9 @@ impl Default for WindowType {
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Hash)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Hash, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum WindowMapping {
/// Map the group values to the position
#[default]
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-python/src/lazyframe/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl NodeTraverser {
// Increment major on breaking changes to the IR (e.g. renaming
// fields, reordering tuples), minor on backwards compatible
// changes (e.g. exposing a new expression node).
const VERSION: Version = (2, 3);
const VERSION: Version = (3, 0);

pub fn new(root: Node, lp_arena: Arena<IR>, expr_arena: Arena<AExpr>) -> Self {
Self {
Expand Down
Loading

0 comments on commit fe016ed

Please sign in to comment.