Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-expr/src/dispatch/range/mod.rs
7884 views
1
use std::sync::Arc;
2
3
use polars_plan::dsl::{ColumnsUdf, SpecialEq};
4
use polars_plan::plans::IRRangeFunction;
5
6
#[cfg(feature = "dtype-datetime")]
7
mod datetime_range;
8
mod int_range;
9
mod linear_space;
10
#[cfg(feature = "dtype-time")]
11
mod time_range;
12
mod utils;
13
14
pub fn function_expr_to_udf(func: IRRangeFunction) -> SpecialEq<Arc<dyn ColumnsUdf>> {
15
use IRRangeFunction::*;
16
match func {
17
IntRange { step, dtype } => {
18
map_as_slice!(int_range::int_range, step, dtype.clone())
19
},
20
IntRanges { dtype } => {
21
map_as_slice!(int_range::int_ranges, dtype.clone())
22
},
23
LinearSpace { closed } => {
24
map_as_slice!(linear_space::linear_space, closed)
25
},
26
LinearSpaces {
27
closed,
28
array_width,
29
} => {
30
map_as_slice!(linear_space::linear_spaces, closed, array_width)
31
},
32
#[cfg(feature = "dtype-date")]
33
DateRange {
34
interval,
35
closed,
36
arg_type,
37
} => {
38
map_as_slice!(datetime_range::date_range, interval, closed, arg_type) // TODO! num_samples
39
},
40
#[cfg(feature = "dtype-date")]
41
DateRanges {
42
interval,
43
closed,
44
arg_type,
45
} => {
46
map_as_slice!(datetime_range::date_ranges, interval, closed, arg_type) // TODO! num_samples
47
},
48
#[cfg(feature = "dtype-datetime")]
49
DatetimeRange {
50
interval,
51
closed,
52
time_unit: _,
53
time_zone: _,
54
arg_type,
55
} => {
56
map_as_slice!(datetime_range::datetime_range, interval, closed, arg_type) // TODO! num_samples
57
},
58
#[cfg(feature = "dtype-datetime")]
59
DatetimeRanges {
60
interval,
61
closed,
62
time_unit: _,
63
time_zone: _,
64
arg_type,
65
} => {
66
map_as_slice!(datetime_range::datetime_ranges, interval, closed, arg_type) // TODO! num_samples
67
},
68
#[cfg(feature = "dtype-time")]
69
TimeRange { interval, closed } => {
70
map_as_slice!(time_range::time_range, interval, closed)
71
},
72
#[cfg(feature = "dtype-time")]
73
TimeRanges { interval, closed } => {
74
map_as_slice!(time_range::time_ranges, interval, closed)
75
},
76
}
77
}
78
79