use polars_ops::prelude::{JoinArgs, JoinType};
#[cfg(feature = "dynamic_group_by")]
use polars_time::RollingGroupOptions;
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;
#[derive(Copy, Clone, PartialEq, Debug, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RollingCovOptions {
pub window_size: IdxSize,
pub min_periods: IdxSize,
pub ddof: u8,
}
#[derive(Clone, PartialEq, Debug, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StrptimeOptions {
pub format: Option<PlSmallStr>,
pub strict: bool,
pub exact: bool,
pub cache: bool,
}
impl Default for StrptimeOptions {
fn default() -> Self {
StrptimeOptions {
format: None,
strict: true,
exact: true,
cache: true,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct JoinOptions {
pub allow_parallel: bool,
pub force_parallel: bool,
pub args: JoinArgs,
pub rows_left: (Option<usize>, usize),
pub rows_right: (Option<usize>, usize),
}
impl Default for JoinOptions {
fn default() -> Self {
JoinOptions {
allow_parallel: true,
force_parallel: false,
args: JoinArgs::new(JoinType::Left),
rows_left: (None, usize::MAX),
rows_right: (None, usize::MAX),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum WindowType {
Over(WindowMapping),
#[cfg(feature = "dynamic_group_by")]
Rolling(RollingGroupOptions),
}
impl From<WindowMapping> for WindowType {
fn from(value: WindowMapping) -> Self {
Self::Over(value)
}
}
impl Default for WindowType {
fn default() -> Self {
Self::Over(WindowMapping::default())
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Hash, IntoStaticStr)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[strum(serialize_all = "snake_case")]
pub enum WindowMapping {
#[default]
GroupsToRows,
Explode,
Join,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum NestedType {
#[cfg(feature = "dtype-array")]
Array,
}
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct UnpivotArgsDSL {
pub on: Vec<Selector>,
pub index: Vec<Selector>,
pub variable_name: Option<PlSmallStr>,
pub value_name: Option<PlSmallStr>,
}