Skip to content

Commit

Permalink
refactor(rust!): Reorganize range expression module (#10871)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Sep 3, 2023
1 parent c9d8740 commit 8ee339e
Show file tree
Hide file tree
Showing 16 changed files with 752 additions and 726 deletions.
24 changes: 0 additions & 24 deletions crates/polars-plan/src/dsl/function_expr/datetime.rs
Expand Up @@ -43,26 +43,6 @@ pub enum TemporalFunction {
Round(String, String),
#[cfg(feature = "timezones")]
ReplaceTimeZone(Option<TimeZone>),
DateRange {
every: Duration,
closed: ClosedWindow,
time_unit: Option<TimeUnit>,
time_zone: Option<TimeZone>,
},
DateRanges {
every: Duration,
closed: ClosedWindow,
time_unit: Option<TimeUnit>,
time_zone: Option<TimeZone>,
},
TimeRange {
every: Duration,
closed: ClosedWindow,
},
TimeRanges {
every: Duration,
closed: ClosedWindow,
},
Combine(TimeUnit),
DatetimeFunction {
time_unit: TimeUnit,
Expand Down Expand Up @@ -105,10 +85,6 @@ impl Display for TemporalFunction {
Round(..) => "round",
#[cfg(feature = "timezones")]
ReplaceTimeZone(_) => "replace_time_zone",
DateRange { .. } => return write!(f, "date_range"),
DateRanges { .. } => return write!(f, "date_ranges"),
TimeRange { .. } => return write!(f, "time_range"),
TimeRanges { .. } => return write!(f, "time_ranges"),
DatetimeFunction { .. } => return write!(f, "datetime"),
Combine(_) => "combine",
};
Expand Down
50 changes: 1 addition & 49 deletions crates/polars-plan/src/dsl/function_expr/mod.rs
Expand Up @@ -380,6 +380,7 @@ macro_rules! wrap {
// Fn(&[Series], args)
// all expression arguments are in the slice.
// the first element is the root expression.
#[macro_export]
macro_rules! map_as_slice {
($func:path) => {{
let f = move |s: &mut [Series]| {
Expand Down Expand Up @@ -765,40 +766,6 @@ impl From<TemporalFunction> for SpecialEq<Arc<dyn SeriesUdf>> {
map_as_slice!(dispatch::replace_time_zone, tz.as_deref())
},
Combine(tu) => map_as_slice!(temporal::combine, tu),
DateRange {
every,
closed,
time_unit,
time_zone,
} => {
map_as_slice!(
temporal::temporal_range,
every,
closed,
time_unit,
time_zone.clone()
)
},
DateRanges {
every,
closed,
time_unit,
time_zone,
} => {
map_as_slice!(
temporal::temporal_ranges,
every,
closed,
time_unit,
time_zone.clone()
)
},
TimeRange { every, closed } => {
map_as_slice!(temporal::time_range, every, closed)
},
TimeRanges { every, closed } => {
map_as_slice!(temporal::time_ranges, every, closed)
},
DatetimeFunction {
time_unit,
time_zone,
Expand All @@ -808,18 +775,3 @@ impl From<TemporalFunction> for SpecialEq<Arc<dyn SeriesUdf>> {
}
}
}

#[cfg(feature = "range")]
impl From<RangeFunction> for SpecialEq<Arc<dyn SeriesUdf>> {
fn from(func: RangeFunction) -> Self {
use RangeFunction::*;
match func {
IntRange { step } => {
map_as_slice!(range::int_range, step)
},
IntRanges { step } => {
map_as_slice!(range::int_ranges, step)
},
}
}
}

0 comments on commit 8ee339e

Please sign in to comment.