1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use vortex_dtype::field::FieldPath;

use crate::expressions::{Predicate, Value};
use crate::operators::Operator;

pub trait FieldPathOperations {
    fn equal(&self, other: Value) -> Predicate;
    fn not_equal(&self, other: Value) -> Predicate;
    fn gt(&self, other: Value) -> Predicate;
    fn gte(&self, other: Value) -> Predicate;
    fn lt(&self, other: Value) -> Predicate;
    fn lte(&self, other: Value) -> Predicate;
}

impl FieldPathOperations for FieldPath {
    // comparisons
    fn equal(&self, other: Value) -> Predicate {
        Predicate {
            lhs: self.clone(),
            op: Operator::Eq,
            rhs: other,
        }
    }

    fn not_equal(&self, other: Value) -> Predicate {
        Predicate {
            lhs: self.clone(),
            op: Operator::NotEq,
            rhs: other,
        }
    }

    fn gt(&self, other: Value) -> Predicate {
        Predicate {
            lhs: self.clone(),
            op: Operator::Gt,
            rhs: other,
        }
    }

    fn gte(&self, other: Value) -> Predicate {
        Predicate {
            lhs: self.clone(),
            op: Operator::Gte,
            rhs: other,
        }
    }

    fn lt(&self, other: Value) -> Predicate {
        Predicate {
            lhs: self.clone(),
            op: Operator::Lt,
            rhs: other,
        }
    }

    fn lte(&self, other: Value) -> Predicate {
        Predicate {
            lhs: self.clone(),
            op: Operator::Lte,
            rhs: other,
        }
    }
}