Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[split/5] move window frame and operator to datafusion-expr module #1761

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datafusion-expr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ path = "src/lib.rs"
[dependencies]
datafusion-common = { path = "../datafusion-common", version = "6.0.0" }
arrow = { version = "8.0.0", features = ["prettyprint"] }
sqlparser = "0.13"
4 changes: 4 additions & 0 deletions datafusion-expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
// under the License.

mod aggregate_function;
mod operator;
mod window_frame;
mod window_function;

pub use aggregate_function::AggregateFunction;
pub use operator::Operator;
pub use window_frame::{WindowFrame, WindowFrameBound, WindowFrameUnits};
pub use window_function::{BuiltInWindowFunction, WindowFunction};
97 changes: 97 additions & 0 deletions datafusion-expr/src/operator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

use std::fmt;

/// Operators applied to expressions
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Hash)]
pub enum Operator {
/// Expressions are equal
Eq,
/// Expressions are not equal
NotEq,
/// Left side is smaller than right side
Lt,
/// Left side is smaller or equal to right side
LtEq,
/// Left side is greater than right side
Gt,
/// Left side is greater or equal to right side
GtEq,
/// Addition
Plus,
/// Subtraction
Minus,
/// Multiplication operator, like `*`
Multiply,
/// Division operator, like `/`
Divide,
/// Remainder operator, like `%`
Modulo,
/// Logical AND, like `&&`
And,
/// Logical OR, like `||`
Or,
/// Matches a wildcard pattern
Like,
/// Does not match a wildcard pattern
NotLike,
/// IS DISTINCT FROM
IsDistinctFrom,
/// IS NOT DISTINCT FROM
IsNotDistinctFrom,
/// Case sensitive regex match
RegexMatch,
/// Case insensitive regex match
RegexIMatch,
/// Case sensitive regex not match
RegexNotMatch,
/// Case insensitive regex not match
RegexNotIMatch,
/// Bitwise and, like `&`
BitwiseAnd,
}

impl fmt::Display for Operator {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let display = match &self {
Operator::Eq => "=",
Operator::NotEq => "!=",
Operator::Lt => "<",
Operator::LtEq => "<=",
Operator::Gt => ">",
Operator::GtEq => ">=",
Operator::Plus => "+",
Operator::Minus => "-",
Operator::Multiply => "*",
Operator::Divide => "/",
Operator::Modulo => "%",
Operator::And => "AND",
Operator::Or => "OR",
Operator::Like => "LIKE",
Operator::NotLike => "NOT LIKE",
Operator::RegexMatch => "~",
Operator::RegexIMatch => "~*",
Operator::RegexNotMatch => "!~",
Operator::RegexNotIMatch => "!~*",
Operator::IsDistinctFrom => "IS DISTINCT FROM",
Operator::IsNotDistinctFrom => "IS NOT DISTINCT FROM",
Operator::BitwiseAnd => "&",
};
write!(f, "{}", display)
}
}
Loading