-
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
Conversation
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.
This looks like a great improvement to me -- thank you @jackwener . I had one style suggestion but I also think this PR could be merged as is
impl Operator { | ||
/// If the operator can be negated, return the negated operator | ||
/// otherwise return None | ||
pub fn negate(&self) -> Option<Operator> { |
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.
👍
datafusion/expr/src/operator.rs
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to suggest replacing _
with an an explicit enumeration of all the other operators, like
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
Codecov Report
@@ Coverage Diff @@
## master #3213 +/- ##
==========================================
- Coverage 85.84% 85.84% -0.01%
==========================================
Files 291 291
Lines 52860 52909 +49
==========================================
+ Hits 45380 45419 +39
- Misses 7480 7490 +10
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
please do not use catch all (_
)
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.
👍
Operator::NotLike => Some(Operator::Like), | ||
Operator::IsDistinctFrom => Some(Operator::IsNotDistinctFrom), | ||
Operator::IsNotDistinctFrom => Some(Operator::IsDistinctFrom), | ||
Operator::Plus |
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.
❤️
Benchmark runs are scheduled for baseline = c8d61d8 and contender = 72487cf. 72487cf is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #.
Rationale for this change
Simplify the code, which make we can reuse the negete opeator.
What changes are included in this PR?
refactor simplify negate
Are there any user-facing changes?