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/binary.rs
6940 views
1
#[cfg(feature = "serde")]
2
use serde::{Deserialize, Serialize};
3
4
use super::*;
5
6
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
8
#[derive(Clone, PartialEq, Debug, Hash)]
9
pub enum BinaryFunction {
10
Contains,
11
StartsWith,
12
EndsWith,
13
#[cfg(feature = "binary_encoding")]
14
HexDecode(bool),
15
#[cfg(feature = "binary_encoding")]
16
HexEncode,
17
#[cfg(feature = "binary_encoding")]
18
Base64Decode(bool),
19
#[cfg(feature = "binary_encoding")]
20
Base64Encode,
21
Size,
22
#[cfg(feature = "binary_encoding")]
23
/// The parameters are destination type, and whether to use little endian
24
/// encoding.
25
Reinterpret(DataTypeExpr, bool),
26
}
27
28
impl Display for BinaryFunction {
29
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
30
use BinaryFunction::*;
31
let s = match self {
32
Contains => "contains",
33
StartsWith => "starts_with",
34
EndsWith => "ends_with",
35
#[cfg(feature = "binary_encoding")]
36
HexDecode(_) => "hex_decode",
37
#[cfg(feature = "binary_encoding")]
38
HexEncode => "hex_encode",
39
#[cfg(feature = "binary_encoding")]
40
Base64Decode(_) => "base64_decode",
41
#[cfg(feature = "binary_encoding")]
42
Base64Encode => "base64_encode",
43
Size => "size_bytes",
44
#[cfg(feature = "binary_encoding")]
45
Reinterpret(_, _) => "reinterpret",
46
};
47
write!(f, "bin.{s}")
48
}
49
}
50
51