mz_expr/scalar/func/impls/
boolean.rs
1use mz_repr::strconv;
11
12sqlfunc!(
13 #[sqlname = "NOT"]
14 #[preserves_uniqueness = true]
15 #[inverse = to_unary!(Not)]
16 #[is_monotone = true]
17 fn not(a: bool) -> bool {
18 !a
19 }
20);
21
22sqlfunc!(
23 #[sqlname = "boolean_to_text"]
24 #[preserves_uniqueness = true]
25 #[inverse = to_unary!(super::CastStringToBool)]
26 #[is_monotone = true]
27 fn cast_bool_to_string<'a>(a: bool) -> &'a str {
28 match a {
29 true => "true",
30 false => "false",
31 }
32 }
33);
34
35sqlfunc!(
36 #[sqlname = "boolean_to_nonstandard_text"]
37 #[preserves_uniqueness = true]
38 #[inverse = to_unary!(super::CastStringToBool)]
39 #[is_monotone = true]
40 fn cast_bool_to_string_nonstandard<'a>(a: bool) -> &'a str {
41 strconv::format_bool_static(a)
46 }
47);
48
49sqlfunc!(
50 #[sqlname = "boolean_to_integer"]
51 #[preserves_uniqueness = true]
52 #[inverse = to_unary!(super::CastInt32ToBool)]
53 #[is_monotone = true]
54 fn cast_bool_to_int32(a: bool) -> i32 {
55 match a {
56 true => 1,
57 false => 0,
58 }
59 }
60);
61
62sqlfunc!(
63 #[sqlname = "boolean_to_bigint"]
64 #[preserves_uniqueness = true]
65 #[inverse = to_unary!(super::CastInt64ToBool)]
66 #[is_monotone = true]
67 fn cast_bool_to_int64(a: bool) -> i64 {
68 match a {
69 true => 1,
70 false => 0,
71 }
72 }
73);