Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/function_expr/mod.rs
8408 views
1
#[cfg(feature = "dtype-array")]
2
mod array;
3
mod binary;
4
#[cfg(feature = "bitwise")]
5
mod bitwise;
6
mod boolean;
7
#[cfg(feature = "business")]
8
mod business;
9
#[cfg(feature = "dtype-categorical")]
10
mod cat;
11
#[cfg(feature = "cov")]
12
mod correlation;
13
#[cfg(feature = "temporal")]
14
mod datetime;
15
#[cfg(feature = "dtype-extension")]
16
mod extension;
17
mod list;
18
mod pow;
19
#[cfg(feature = "random")]
20
mod random;
21
#[cfg(feature = "range")]
22
mod range;
23
#[cfg(feature = "rolling_window")]
24
mod rolling;
25
#[cfg(feature = "rolling_window_by")]
26
mod rolling_by;
27
#[cfg(feature = "strings")]
28
mod strings;
29
#[cfg(feature = "dtype-struct")]
30
mod struct_;
31
#[cfg(feature = "trigonometry")]
32
mod trigonometry;
33
34
use std::fmt::{Display, Formatter};
35
use std::hash::{Hash, Hasher};
36
37
#[cfg(feature = "dtype-array")]
38
pub use array::ArrayFunction;
39
#[cfg(feature = "cov")]
40
pub use correlation::CorrelationMethod;
41
pub use list::ListFunction;
42
pub use polars_core::datatypes::ReshapeDimension;
43
use polars_core::prelude::*;
44
#[cfg(feature = "random")]
45
pub use random::RandomMethod;
46
#[cfg(feature = "serde")]
47
use serde::{Deserialize, Serialize};
48
49
pub use self::binary::BinaryFunction;
50
#[cfg(feature = "bitwise")]
51
pub use self::bitwise::BitwiseFunction;
52
pub use self::boolean::BooleanFunction;
53
#[cfg(feature = "business")]
54
pub use self::business::BusinessFunction;
55
#[cfg(feature = "dtype-categorical")]
56
pub use self::cat::CategoricalFunction;
57
#[cfg(feature = "temporal")]
58
pub use self::datetime::TemporalFunction;
59
#[cfg(feature = "dtype-extension")]
60
pub use self::extension::ExtensionFunction;
61
pub use self::pow::PowFunction;
62
#[cfg(feature = "range")]
63
pub use self::range::{DateRangeArgs, RangeFunction};
64
#[cfg(feature = "rolling_window")]
65
pub use self::rolling::RollingFunction;
66
#[cfg(feature = "rolling_window_by")]
67
pub use self::rolling_by::RollingFunctionBy;
68
#[cfg(feature = "strings")]
69
pub use self::strings::StringFunction;
70
#[cfg(feature = "dtype-struct")]
71
pub use self::struct_::StructFunction;
72
#[cfg(feature = "trigonometry")]
73
pub use self::trigonometry::TrigonometricFunction;
74
use super::*;
75
76
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
77
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
78
#[derive(Clone, PartialEq, Debug)]
79
pub enum FunctionExpr {
80
// Namespaces
81
#[cfg(feature = "dtype-array")]
82
ArrayExpr(ArrayFunction),
83
BinaryExpr(BinaryFunction),
84
#[cfg(feature = "dtype-categorical")]
85
Categorical(CategoricalFunction),
86
#[cfg(feature = "dtype-extension")]
87
Extension(ExtensionFunction),
88
ListExpr(ListFunction),
89
#[cfg(feature = "strings")]
90
StringExpr(StringFunction),
91
#[cfg(feature = "dtype-struct")]
92
StructExpr(StructFunction),
93
#[cfg(feature = "temporal")]
94
TemporalExpr(TemporalFunction),
95
#[cfg(feature = "bitwise")]
96
Bitwise(BitwiseFunction),
97
98
// Other expressions
99
Boolean(BooleanFunction),
100
#[cfg(feature = "business")]
101
Business(BusinessFunction),
102
#[cfg(feature = "abs")]
103
Abs,
104
Negate,
105
#[cfg(feature = "hist")]
106
Hist {
107
bin_count: Option<usize>,
108
include_category: bool,
109
include_breakpoint: bool,
110
},
111
NullCount,
112
Pow(PowFunction),
113
#[cfg(feature = "row_hash")]
114
Hash(u64, u64, u64, u64),
115
#[cfg(feature = "arg_where")]
116
ArgWhere,
117
#[cfg(feature = "index_of")]
118
IndexOf,
119
#[cfg(feature = "search_sorted")]
120
SearchSorted {
121
side: SearchSortedSide,
122
descending: bool,
123
},
124
#[cfg(feature = "range")]
125
Range(RangeFunction),
126
#[cfg(feature = "trigonometry")]
127
Trigonometry(TrigonometricFunction),
128
#[cfg(feature = "trigonometry")]
129
Atan2,
130
#[cfg(feature = "sign")]
131
Sign,
132
FillNull,
133
FillNullWithStrategy(FillNullStrategy),
134
#[cfg(feature = "rolling_window")]
135
RollingExpr {
136
function: RollingFunction,
137
options: RollingOptionsFixedWindow,
138
},
139
#[cfg(feature = "rolling_window_by")]
140
RollingExprBy {
141
function_by: RollingFunctionBy,
142
options: RollingOptionsDynamicWindow,
143
},
144
Rechunk,
145
Append {
146
upcast: bool,
147
},
148
ShiftAndFill,
149
Shift,
150
DropNans,
151
DropNulls,
152
#[cfg(feature = "mode")]
153
Mode {
154
maintain_order: bool,
155
},
156
#[cfg(feature = "moment")]
157
Skew(bool),
158
#[cfg(feature = "moment")]
159
Kurtosis(bool, bool),
160
#[cfg(feature = "dtype-array")]
161
Reshape(Vec<ReshapeDimension>),
162
#[cfg(feature = "repeat_by")]
163
RepeatBy,
164
ArgUnique,
165
ArgMin,
166
ArgMax,
167
ArgSort {
168
descending: bool,
169
nulls_last: bool,
170
},
171
MinBy,
172
MaxBy,
173
Product,
174
#[cfg(feature = "rank")]
175
Rank {
176
options: RankOptions,
177
seed: Option<u64>,
178
},
179
Repeat,
180
#[cfg(feature = "round_series")]
181
Clip {
182
has_min: bool,
183
has_max: bool,
184
},
185
#[cfg(feature = "dtype-struct")]
186
AsStruct,
187
#[cfg(feature = "top_k")]
188
TopK {
189
descending: bool,
190
},
191
#[cfg(feature = "top_k")]
192
TopKBy {
193
descending: Vec<bool>,
194
},
195
#[cfg(feature = "cum_agg")]
196
CumCount {
197
reverse: bool,
198
},
199
#[cfg(feature = "cum_agg")]
200
CumSum {
201
reverse: bool,
202
},
203
#[cfg(feature = "cum_agg")]
204
CumProd {
205
reverse: bool,
206
},
207
#[cfg(feature = "cum_agg")]
208
CumMin {
209
reverse: bool,
210
},
211
#[cfg(feature = "cum_agg")]
212
CumMax {
213
reverse: bool,
214
},
215
Reverse,
216
#[cfg(feature = "dtype-struct")]
217
ValueCounts {
218
sort: bool,
219
parallel: bool,
220
name: PlSmallStr,
221
normalize: bool,
222
},
223
#[cfg(feature = "unique_counts")]
224
UniqueCounts,
225
#[cfg(feature = "approx_unique")]
226
ApproxNUnique,
227
Coalesce,
228
#[cfg(feature = "diff")]
229
Diff(NullBehavior),
230
#[cfg(feature = "pct_change")]
231
PctChange,
232
#[cfg(feature = "interpolate")]
233
Interpolate(InterpolationMethod),
234
#[cfg(feature = "interpolate_by")]
235
InterpolateBy,
236
#[cfg(feature = "log")]
237
Entropy {
238
base: f64,
239
normalize: bool,
240
},
241
#[cfg(feature = "log")]
242
Log,
243
#[cfg(feature = "log")]
244
Log1p,
245
#[cfg(feature = "log")]
246
Exp,
247
Unique(bool),
248
#[cfg(feature = "round_series")]
249
Round {
250
decimals: u32,
251
mode: RoundMode,
252
},
253
#[cfg(feature = "round_series")]
254
RoundSF {
255
digits: i32,
256
},
257
#[cfg(feature = "round_series")]
258
Floor,
259
#[cfg(feature = "round_series")]
260
Ceil,
261
UpperBound,
262
LowerBound,
263
ConcatExpr(bool),
264
#[cfg(feature = "cov")]
265
Correlation {
266
method: correlation::CorrelationMethod,
267
},
268
#[cfg(feature = "peaks")]
269
PeakMin,
270
#[cfg(feature = "peaks")]
271
PeakMax,
272
#[cfg(feature = "cutqcut")]
273
Cut {
274
breaks: Vec<f64>,
275
labels: Option<Vec<PlSmallStr>>,
276
left_closed: bool,
277
include_breaks: bool,
278
},
279
#[cfg(feature = "cutqcut")]
280
QCut {
281
probs: Vec<f64>,
282
labels: Option<Vec<PlSmallStr>>,
283
left_closed: bool,
284
allow_duplicates: bool,
285
include_breaks: bool,
286
},
287
#[cfg(feature = "rle")]
288
RLE,
289
#[cfg(feature = "rle")]
290
RLEID,
291
ToPhysical,
292
#[cfg(feature = "random")]
293
Random {
294
method: random::RandomMethod,
295
seed: Option<u64>,
296
},
297
SetSortedFlag(IsSorted),
298
#[cfg(feature = "ffi_plugin")]
299
/// Creating this node is unsafe
300
/// This will lead to calls over FFI.
301
FfiPlugin {
302
flags: FunctionOptions,
303
/// Shared library.
304
lib: PlSmallStr,
305
/// Identifier in the shared lib.
306
symbol: PlSmallStr,
307
/// Pickle serialized keyword arguments.
308
kwargs: Arc<[u8]>,
309
},
310
311
FoldHorizontal {
312
callback: PlanCallback<(Series, Series), Series>,
313
returns_scalar: bool,
314
return_dtype: Option<DataTypeExpr>,
315
},
316
ReduceHorizontal {
317
callback: PlanCallback<(Series, Series), Series>,
318
returns_scalar: bool,
319
return_dtype: Option<DataTypeExpr>,
320
},
321
#[cfg(feature = "dtype-struct")]
322
CumReduceHorizontal {
323
callback: PlanCallback<(Series, Series), Series>,
324
returns_scalar: bool,
325
return_dtype: Option<DataTypeExpr>,
326
},
327
#[cfg(feature = "dtype-struct")]
328
CumFoldHorizontal {
329
callback: PlanCallback<(Series, Series), Series>,
330
returns_scalar: bool,
331
return_dtype: Option<DataTypeExpr>,
332
include_init: bool,
333
},
334
335
MaxHorizontal,
336
MinHorizontal,
337
SumHorizontal {
338
ignore_nulls: bool,
339
},
340
MeanHorizontal {
341
ignore_nulls: bool,
342
},
343
#[cfg(feature = "ewma")]
344
EwmMean {
345
options: EWMOptions,
346
},
347
#[cfg(feature = "ewma_by")]
348
EwmMeanBy {
349
half_life: Duration,
350
},
351
#[cfg(feature = "ewma")]
352
EwmStd {
353
options: EWMOptions,
354
},
355
#[cfg(feature = "ewma")]
356
EwmVar {
357
options: EWMOptions,
358
},
359
#[cfg(feature = "replace")]
360
Replace,
361
#[cfg(feature = "replace")]
362
ReplaceStrict {
363
return_dtype: Option<DataTypeExpr>,
364
},
365
GatherEvery {
366
n: usize,
367
offset: usize,
368
},
369
#[cfg(feature = "reinterpret")]
370
Reinterpret(bool),
371
ExtendConstant,
372
373
RowEncode(RowEncodingVariant),
374
#[cfg(feature = "dtype-struct")]
375
RowDecode(Vec<(PlSmallStr, DataTypeExpr)>, RowEncodingVariant),
376
}
377
378
impl Hash for FunctionExpr {
379
fn hash<H: Hasher>(&self, state: &mut H) {
380
std::mem::discriminant(self).hash(state);
381
use FunctionExpr::*;
382
match self {
383
// Namespaces
384
#[cfg(feature = "dtype-array")]
385
ArrayExpr(f) => f.hash(state),
386
BinaryExpr(f) => f.hash(state),
387
#[cfg(feature = "dtype-categorical")]
388
Categorical(f) => f.hash(state),
389
#[cfg(feature = "dtype-extension")]
390
Extension(f) => f.hash(state),
391
ListExpr(f) => f.hash(state),
392
#[cfg(feature = "strings")]
393
StringExpr(f) => f.hash(state),
394
#[cfg(feature = "dtype-struct")]
395
StructExpr(f) => f.hash(state),
396
#[cfg(feature = "temporal")]
397
TemporalExpr(f) => f.hash(state),
398
#[cfg(feature = "bitwise")]
399
Bitwise(f) => f.hash(state),
400
401
// Other expressions
402
Boolean(f) => f.hash(state),
403
#[cfg(feature = "business")]
404
Business(f) => f.hash(state),
405
Pow(f) => f.hash(state),
406
#[cfg(feature = "index_of")]
407
IndexOf => {},
408
#[cfg(feature = "search_sorted")]
409
SearchSorted { side, descending } => {
410
side.hash(state);
411
descending.hash(state);
412
},
413
#[cfg(feature = "random")]
414
Random { method, .. } => method.hash(state),
415
#[cfg(feature = "cov")]
416
Correlation { method, .. } => method.hash(state),
417
#[cfg(feature = "range")]
418
Range(f) => f.hash(state),
419
#[cfg(feature = "trigonometry")]
420
Trigonometry(f) => f.hash(state),
421
#[cfg(feature = "diff")]
422
Diff(null_behavior) => null_behavior.hash(state),
423
#[cfg(feature = "interpolate")]
424
Interpolate(f) => f.hash(state),
425
#[cfg(feature = "interpolate_by")]
426
InterpolateBy => {},
427
#[cfg(feature = "ffi_plugin")]
428
FfiPlugin {
429
flags: _,
430
lib,
431
symbol,
432
kwargs,
433
} => {
434
kwargs.hash(state);
435
lib.hash(state);
436
symbol.hash(state);
437
},
438
439
FoldHorizontal {
440
callback,
441
returns_scalar,
442
return_dtype,
443
}
444
| ReduceHorizontal {
445
callback,
446
returns_scalar,
447
return_dtype,
448
} => {
449
callback.hash(state);
450
returns_scalar.hash(state);
451
return_dtype.hash(state);
452
},
453
#[cfg(feature = "dtype-struct")]
454
CumReduceHorizontal {
455
callback,
456
returns_scalar,
457
return_dtype,
458
} => {
459
callback.hash(state);
460
returns_scalar.hash(state);
461
return_dtype.hash(state);
462
},
463
#[cfg(feature = "dtype-struct")]
464
CumFoldHorizontal {
465
callback,
466
returns_scalar,
467
return_dtype,
468
include_init,
469
} => {
470
callback.hash(state);
471
returns_scalar.hash(state);
472
return_dtype.hash(state);
473
include_init.hash(state);
474
},
475
SumHorizontal { ignore_nulls } | MeanHorizontal { ignore_nulls } => {
476
ignore_nulls.hash(state)
477
},
478
MaxHorizontal | MinHorizontal | DropNans | DropNulls | Reverse | ArgUnique | ArgMin
479
| ArgMax | Product | Shift | ShiftAndFill | Rechunk | MinBy | MaxBy => {},
480
Append { upcast } => upcast.hash(state),
481
ArgSort {
482
descending,
483
nulls_last,
484
} => {
485
descending.hash(state);
486
nulls_last.hash(state);
487
},
488
#[cfg(feature = "mode")]
489
Mode { maintain_order } => maintain_order.hash(state),
490
#[cfg(feature = "abs")]
491
Abs => {},
492
Negate => {},
493
NullCount => {},
494
#[cfg(feature = "arg_where")]
495
ArgWhere => {},
496
#[cfg(feature = "trigonometry")]
497
Atan2 => {},
498
#[cfg(feature = "dtype-struct")]
499
AsStruct => {},
500
#[cfg(feature = "sign")]
501
Sign => {},
502
#[cfg(feature = "row_hash")]
503
Hash(a, b, c, d) => (a, b, c, d).hash(state),
504
FillNull => {},
505
#[cfg(feature = "rolling_window")]
506
RollingExpr { function, options } => {
507
function.hash(state);
508
options.hash(state);
509
},
510
#[cfg(feature = "rolling_window_by")]
511
RollingExprBy {
512
function_by,
513
options,
514
} => {
515
function_by.hash(state);
516
options.hash(state);
517
},
518
#[cfg(feature = "moment")]
519
Skew(a) => a.hash(state),
520
#[cfg(feature = "moment")]
521
Kurtosis(a, b) => {
522
a.hash(state);
523
b.hash(state);
524
},
525
Repeat => {},
526
#[cfg(feature = "rank")]
527
Rank { options, seed } => {
528
options.hash(state);
529
seed.hash(state);
530
},
531
#[cfg(feature = "round_series")]
532
Clip { has_min, has_max } => {
533
has_min.hash(state);
534
has_max.hash(state);
535
},
536
#[cfg(feature = "top_k")]
537
TopK { descending } => descending.hash(state),
538
#[cfg(feature = "cum_agg")]
539
CumCount { reverse } => reverse.hash(state),
540
#[cfg(feature = "cum_agg")]
541
CumSum { reverse } => reverse.hash(state),
542
#[cfg(feature = "cum_agg")]
543
CumProd { reverse } => reverse.hash(state),
544
#[cfg(feature = "cum_agg")]
545
CumMin { reverse } => reverse.hash(state),
546
#[cfg(feature = "cum_agg")]
547
CumMax { reverse } => reverse.hash(state),
548
#[cfg(feature = "dtype-struct")]
549
ValueCounts {
550
sort,
551
parallel,
552
name,
553
normalize,
554
} => {
555
sort.hash(state);
556
parallel.hash(state);
557
name.hash(state);
558
normalize.hash(state);
559
},
560
#[cfg(feature = "unique_counts")]
561
UniqueCounts => {},
562
#[cfg(feature = "approx_unique")]
563
ApproxNUnique => {},
564
Coalesce => {},
565
#[cfg(feature = "pct_change")]
566
PctChange => {},
567
#[cfg(feature = "log")]
568
Entropy { base, normalize } => {
569
base.to_bits().hash(state);
570
normalize.hash(state);
571
},
572
#[cfg(feature = "log")]
573
Log => {},
574
#[cfg(feature = "log")]
575
Log1p => {},
576
#[cfg(feature = "log")]
577
Exp => {},
578
Unique(a) => a.hash(state),
579
#[cfg(feature = "round_series")]
580
Round { decimals, mode } => {
581
decimals.hash(state);
582
mode.hash(state);
583
},
584
#[cfg(feature = "round_series")]
585
FunctionExpr::RoundSF { digits } => digits.hash(state),
586
#[cfg(feature = "round_series")]
587
FunctionExpr::Floor => {},
588
#[cfg(feature = "round_series")]
589
Ceil => {},
590
UpperBound => {},
591
LowerBound => {},
592
ConcatExpr(a) => a.hash(state),
593
#[cfg(feature = "peaks")]
594
PeakMin => {},
595
#[cfg(feature = "peaks")]
596
PeakMax => {},
597
#[cfg(feature = "cutqcut")]
598
Cut {
599
breaks,
600
labels,
601
left_closed,
602
include_breaks,
603
} => {
604
let slice = bytemuck::cast_slice::<_, u64>(breaks);
605
slice.hash(state);
606
labels.hash(state);
607
left_closed.hash(state);
608
include_breaks.hash(state);
609
},
610
#[cfg(feature = "dtype-array")]
611
Reshape(dims) => dims.hash(state),
612
#[cfg(feature = "repeat_by")]
613
RepeatBy => {},
614
#[cfg(feature = "cutqcut")]
615
QCut {
616
probs,
617
labels,
618
left_closed,
619
allow_duplicates,
620
include_breaks,
621
} => {
622
let slice = bytemuck::cast_slice::<_, u64>(probs);
623
slice.hash(state);
624
labels.hash(state);
625
left_closed.hash(state);
626
allow_duplicates.hash(state);
627
include_breaks.hash(state);
628
},
629
#[cfg(feature = "rle")]
630
RLE => {},
631
#[cfg(feature = "rle")]
632
RLEID => {},
633
ToPhysical => {},
634
SetSortedFlag(is_sorted) => is_sorted.hash(state),
635
#[cfg(feature = "ewma")]
636
EwmMean { options } => options.hash(state),
637
#[cfg(feature = "ewma_by")]
638
EwmMeanBy { half_life } => (half_life).hash(state),
639
#[cfg(feature = "ewma")]
640
EwmStd { options } => options.hash(state),
641
#[cfg(feature = "ewma")]
642
EwmVar { options } => options.hash(state),
643
#[cfg(feature = "hist")]
644
Hist {
645
bin_count,
646
include_category,
647
include_breakpoint,
648
} => {
649
bin_count.hash(state);
650
include_category.hash(state);
651
include_breakpoint.hash(state);
652
},
653
#[cfg(feature = "replace")]
654
Replace => {},
655
#[cfg(feature = "replace")]
656
ReplaceStrict { return_dtype } => return_dtype.hash(state),
657
FillNullWithStrategy(strategy) => strategy.hash(state),
658
GatherEvery { n, offset } => (n, offset).hash(state),
659
#[cfg(feature = "reinterpret")]
660
Reinterpret(signed) => signed.hash(state),
661
ExtendConstant => {},
662
#[cfg(feature = "top_k")]
663
TopKBy { descending } => descending.hash(state),
664
665
RowEncode(variants) => variants.hash(state),
666
#[cfg(feature = "dtype-struct")]
667
RowDecode(fs, variants) => {
668
fs.hash(state);
669
variants.hash(state);
670
},
671
}
672
}
673
}
674
675
impl Display for FunctionExpr {
676
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
677
use FunctionExpr::*;
678
let s = match self {
679
// Namespaces
680
#[cfg(feature = "dtype-array")]
681
ArrayExpr(func) => return write!(f, "{func}"),
682
BinaryExpr(func) => return write!(f, "{func}"),
683
#[cfg(feature = "dtype-categorical")]
684
Categorical(func) => return write!(f, "{func}"),
685
#[cfg(feature = "dtype-extension")]
686
Extension(func) => return write!(f, "{func}"),
687
ListExpr(func) => return write!(f, "{func}"),
688
#[cfg(feature = "strings")]
689
StringExpr(func) => return write!(f, "{func}"),
690
#[cfg(feature = "dtype-struct")]
691
StructExpr(func) => return write!(f, "{func}"),
692
#[cfg(feature = "temporal")]
693
TemporalExpr(func) => return write!(f, "{func}"),
694
#[cfg(feature = "bitwise")]
695
Bitwise(func) => return write!(f, "bitwise_{func}"),
696
697
// Other expressions
698
Boolean(func) => return write!(f, "{func}"),
699
#[cfg(feature = "business")]
700
Business(func) => return write!(f, "{func}"),
701
#[cfg(feature = "abs")]
702
Abs => "abs",
703
Negate => "negate",
704
NullCount => "null_count",
705
Pow(func) => return write!(f, "{func}"),
706
#[cfg(feature = "row_hash")]
707
Hash(_, _, _, _) => "hash",
708
#[cfg(feature = "arg_where")]
709
ArgWhere => "arg_where",
710
#[cfg(feature = "index_of")]
711
IndexOf => "index_of",
712
#[cfg(feature = "search_sorted")]
713
SearchSorted { .. } => "search_sorted",
714
#[cfg(feature = "range")]
715
Range(func) => return write!(f, "{func}"),
716
#[cfg(feature = "trigonometry")]
717
Trigonometry(func) => return write!(f, "{func}"),
718
#[cfg(feature = "trigonometry")]
719
Atan2 => return write!(f, "arctan2"),
720
#[cfg(feature = "sign")]
721
Sign => "sign",
722
FillNull => "fill_null",
723
#[cfg(feature = "rolling_window")]
724
RollingExpr { function, .. } => return write!(f, "{function}"),
725
#[cfg(feature = "rolling_window_by")]
726
RollingExprBy { function_by, .. } => return write!(f, "{function_by}"),
727
Rechunk => "rechunk",
728
Append { .. } => "upcast",
729
ShiftAndFill => "shift_and_fill",
730
DropNans => "drop_nans",
731
DropNulls => "drop_nulls",
732
#[cfg(feature = "mode")]
733
Mode { maintain_order } => {
734
if *maintain_order {
735
"mode_stable"
736
} else {
737
"mode"
738
}
739
},
740
#[cfg(feature = "moment")]
741
Skew(_) => "skew",
742
#[cfg(feature = "moment")]
743
Kurtosis(..) => "kurtosis",
744
ArgUnique => "arg_unique",
745
ArgMin => "arg_min",
746
ArgMax => "arg_max",
747
ArgSort { .. } => "arg_sort",
748
MinBy => "min_by",
749
MaxBy => "max_by",
750
Product => "product",
751
Repeat => "repeat",
752
#[cfg(feature = "rank")]
753
Rank { .. } => "rank",
754
#[cfg(feature = "round_series")]
755
Clip { has_min, has_max } => match (has_min, has_max) {
756
(true, true) => "clip",
757
(false, true) => "clip_max",
758
(true, false) => "clip_min",
759
_ => unreachable!(),
760
},
761
#[cfg(feature = "dtype-struct")]
762
AsStruct => "as_struct",
763
#[cfg(feature = "top_k")]
764
TopK { descending } => {
765
if *descending {
766
"bottom_k"
767
} else {
768
"top_k"
769
}
770
},
771
#[cfg(feature = "top_k")]
772
TopKBy { .. } => "top_k_by",
773
Shift => "shift",
774
#[cfg(feature = "cum_agg")]
775
CumCount { .. } => "cum_count",
776
#[cfg(feature = "cum_agg")]
777
CumSum { .. } => "cum_sum",
778
#[cfg(feature = "cum_agg")]
779
CumProd { .. } => "cum_prod",
780
#[cfg(feature = "cum_agg")]
781
CumMin { .. } => "cum_min",
782
#[cfg(feature = "cum_agg")]
783
CumMax { .. } => "cum_max",
784
#[cfg(feature = "dtype-struct")]
785
ValueCounts { .. } => "value_counts",
786
#[cfg(feature = "unique_counts")]
787
UniqueCounts => "unique_counts",
788
Reverse => "reverse",
789
#[cfg(feature = "approx_unique")]
790
ApproxNUnique => "approx_n_unique",
791
Coalesce => "coalesce",
792
#[cfg(feature = "diff")]
793
Diff(_) => "diff",
794
#[cfg(feature = "pct_change")]
795
PctChange => "pct_change",
796
#[cfg(feature = "interpolate")]
797
Interpolate(_) => "interpolate",
798
#[cfg(feature = "interpolate_by")]
799
InterpolateBy => "interpolate_by",
800
#[cfg(feature = "log")]
801
Entropy { .. } => "entropy",
802
#[cfg(feature = "log")]
803
Log => "log",
804
#[cfg(feature = "log")]
805
Log1p => "log1p",
806
#[cfg(feature = "log")]
807
Exp => "exp",
808
Unique(stable) => {
809
if *stable {
810
"unique_stable"
811
} else {
812
"unique"
813
}
814
},
815
#[cfg(feature = "round_series")]
816
Round { .. } => "round",
817
#[cfg(feature = "round_series")]
818
RoundSF { .. } => "round_sig_figs",
819
#[cfg(feature = "round_series")]
820
Floor => "floor",
821
#[cfg(feature = "round_series")]
822
Ceil => "ceil",
823
UpperBound => "upper_bound",
824
LowerBound => "lower_bound",
825
ConcatExpr(_) => "concat_expr",
826
#[cfg(feature = "cov")]
827
Correlation { method, .. } => return Display::fmt(method, f),
828
#[cfg(feature = "peaks")]
829
PeakMin => "peak_min",
830
#[cfg(feature = "peaks")]
831
PeakMax => "peak_max",
832
#[cfg(feature = "cutqcut")]
833
Cut { .. } => "cut",
834
#[cfg(feature = "cutqcut")]
835
QCut { .. } => "qcut",
836
#[cfg(feature = "dtype-array")]
837
Reshape(_) => "reshape",
838
#[cfg(feature = "repeat_by")]
839
RepeatBy => "repeat_by",
840
#[cfg(feature = "rle")]
841
RLE => "rle",
842
#[cfg(feature = "rle")]
843
RLEID => "rle_id",
844
ToPhysical => "to_physical",
845
#[cfg(feature = "random")]
846
Random { method, .. } => method.into(),
847
SetSortedFlag(_) => "set_sorted",
848
#[cfg(feature = "ffi_plugin")]
849
FfiPlugin { lib, symbol, .. } => return write!(f, "{lib}:{symbol}"),
850
FoldHorizontal { .. } => "fold",
851
ReduceHorizontal { .. } => "reduce",
852
#[cfg(feature = "dtype-struct")]
853
CumReduceHorizontal { .. } => "cum_reduce",
854
#[cfg(feature = "dtype-struct")]
855
CumFoldHorizontal { .. } => "cum_fold",
856
MaxHorizontal => "max_horizontal",
857
MinHorizontal => "min_horizontal",
858
SumHorizontal { .. } => "sum_horizontal",
859
MeanHorizontal { .. } => "mean_horizontal",
860
#[cfg(feature = "ewma")]
861
EwmMean { .. } => "ewm_mean",
862
#[cfg(feature = "ewma_by")]
863
EwmMeanBy { .. } => "ewm_mean_by",
864
#[cfg(feature = "ewma")]
865
EwmStd { .. } => "ewm_std",
866
#[cfg(feature = "ewma")]
867
EwmVar { .. } => "ewm_var",
868
#[cfg(feature = "hist")]
869
Hist { .. } => "hist",
870
#[cfg(feature = "replace")]
871
Replace => "replace",
872
#[cfg(feature = "replace")]
873
ReplaceStrict { .. } => "replace_strict",
874
FillNullWithStrategy(_) => "fill_null_with_strategy",
875
GatherEvery { .. } => "gather_every",
876
#[cfg(feature = "reinterpret")]
877
Reinterpret(_) => "reinterpret",
878
ExtendConstant => "extend_constant",
879
880
RowEncode(..) => "row_encode",
881
#[cfg(feature = "dtype-struct")]
882
RowDecode(..) => "row_decode",
883
};
884
write!(f, "{s}")
885
}
886
}
887
888
#[cfg(any(feature = "array_to_struct", feature = "list_to_struct"))]
889
pub type DslNameGenerator = PlanCallback<usize, String>;
890
891