Skip to content

Commit 798f3f1

Browse files
committed
include window frames and operator into datafusion-expr
1 parent a39a223 commit 798f3f1

File tree

6 files changed

+487
-442
lines changed

6 files changed

+487
-442
lines changed

datafusion-expr/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ path = "src/lib.rs"
3737
[dependencies]
3838
datafusion-common = { path = "../datafusion-common", version = "6.0.0" }
3939
arrow = { version = "8.0.0", features = ["prettyprint"] }
40+
sqlparser = "0.13"

datafusion-expr/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
// under the License.
1717

1818
mod aggregate_function;
19+
mod operator;
20+
mod window_frame;
1921
mod window_function;
2022

2123
pub use aggregate_function::AggregateFunction;
24+
pub use operator::Operator;
25+
pub use window_frame::{WindowFrame, WindowFrameBound, WindowFrameUnits};
2226
pub use window_function::{BuiltInWindowFunction, WindowFunction};

datafusion-expr/src/operator.rs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use std::fmt;
19+
20+
/// Operators applied to expressions
21+
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Hash)]
22+
pub enum Operator {
23+
/// Expressions are equal
24+
Eq,
25+
/// Expressions are not equal
26+
NotEq,
27+
/// Left side is smaller than right side
28+
Lt,
29+
/// Left side is smaller or equal to right side
30+
LtEq,
31+
/// Left side is greater than right side
32+
Gt,
33+
/// Left side is greater or equal to right side
34+
GtEq,
35+
/// Addition
36+
Plus,
37+
/// Subtraction
38+
Minus,
39+
/// Multiplication operator, like `*`
40+
Multiply,
41+
/// Division operator, like `/`
42+
Divide,
43+
/// Remainder operator, like `%`
44+
Modulo,
45+
/// Logical AND, like `&&`
46+
And,
47+
/// Logical OR, like `||`
48+
Or,
49+
/// Matches a wildcard pattern
50+
Like,
51+
/// Does not match a wildcard pattern
52+
NotLike,
53+
/// IS DISTINCT FROM
54+
IsDistinctFrom,
55+
/// IS NOT DISTINCT FROM
56+
IsNotDistinctFrom,
57+
/// Case sensitive regex match
58+
RegexMatch,
59+
/// Case insensitive regex match
60+
RegexIMatch,
61+
/// Case sensitive regex not match
62+
RegexNotMatch,
63+
/// Case insensitive regex not match
64+
RegexNotIMatch,
65+
/// Bitwise and, like `&`
66+
BitwiseAnd,
67+
}
68+
69+
impl fmt::Display for Operator {
70+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
71+
let display = match &self {
72+
Operator::Eq => "=",
73+
Operator::NotEq => "!=",
74+
Operator::Lt => "<",
75+
Operator::LtEq => "<=",
76+
Operator::Gt => ">",
77+
Operator::GtEq => ">=",
78+
Operator::Plus => "+",
79+
Operator::Minus => "-",
80+
Operator::Multiply => "*",
81+
Operator::Divide => "/",
82+
Operator::Modulo => "%",
83+
Operator::And => "AND",
84+
Operator::Or => "OR",
85+
Operator::Like => "LIKE",
86+
Operator::NotLike => "NOT LIKE",
87+
Operator::RegexMatch => "~",
88+
Operator::RegexIMatch => "~*",
89+
Operator::RegexNotMatch => "!~",
90+
Operator::RegexNotIMatch => "!~*",
91+
Operator::IsDistinctFrom => "IS DISTINCT FROM",
92+
Operator::IsNotDistinctFrom => "IS NOT DISTINCT FROM",
93+
Operator::BitwiseAnd => "&",
94+
};
95+
write!(f, "{}", display)
96+
}
97+
}

0 commit comments

Comments
 (0)