-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
minor: refactor simplify negate #3213
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,26 @@ pub enum Operator { | |
StringConcat, | ||
} | ||
|
||
impl Operator { | ||
/// If the operator can be negated, return the negated operator | ||
/// otherwise return None | ||
pub fn negate(&self) -> Option<Operator> { | ||
match self { | ||
Operator::Eq => Some(Operator::NotEq), | ||
Operator::NotEq => Some(Operator::Eq), | ||
Operator::Lt => Some(Operator::GtEq), | ||
Operator::LtEq => Some(Operator::Gt), | ||
Operator::Gt => Some(Operator::LtEq), | ||
Operator::GtEq => Some(Operator::Lt), | ||
Operator::Like => Some(Operator::NotLike), | ||
Operator::NotLike => Some(Operator::Like), | ||
Operator::IsDistinctFrom => Some(Operator::IsNotDistinctFrom), | ||
Operator::IsNotDistinctFrom => Some(Operator::IsDistinctFrom), | ||
_ => None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to suggest replacing Operator::LeftShift | OperatiorRightShift => None The reason is so that as new operators are added, the compiler will point us at this code and we will get another chance to avoid bugs like https://github.com/apache/arrow-datafusion/pull/3167/files#r946145318 |
||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for Operator { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
let display = match &self { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍