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

minor: refactor simplify negate #3213

Merged
merged 2 commits into from
Aug 21, 2022
Merged

minor: refactor simplify negate #3213

merged 2 commits into from
Aug 21, 2022

Conversation

jackwener
Copy link
Member

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?

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Aug 20, 2022
Copy link
Contributor

@alamb alamb left a 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> {
Copy link
Contributor

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),
_ => None,
Copy link
Contributor

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-commenter
Copy link

codecov-commenter commented Aug 20, 2022

Codecov Report

Merging #3213 (d1d02d1) into master (e0a9fa3) will decrease coverage by 0.00%.
The diff coverage is 93.75%.

@@            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     
Impacted Files Coverage Δ
datafusion/expr/src/operator.rs 95.23% <92.30%> (-0.77%) ⬇️
datafusion/optimizer/src/simplify_expressions.rs 84.00% <100.00%> (+0.06%) ⬆️
datafusion/expr/src/utils.rs 90.02% <0.00%> (-0.74%) ⬇️
datafusion/core/src/physical_plan/metrics/value.rs 86.93% <0.00%> (-0.51%) ⬇️
datafusion/core/src/physical_plan/planner.rs 80.88% <0.00%> (-0.17%) ⬇️
datafusion/proto/src/logical_plan.rs 17.35% <0.00%> (-0.07%) ⬇️
datafusion/sql/src/planner.rs 80.62% <0.00%> (-0.07%) ⬇️
datafusion/expr/src/logical_plan/plan.rs 78.00% <0.00%> (+0.22%) ⬆️
datafusion/expr/src/logical_plan/builder.rs 90.35% <0.00%> (+0.70%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@jimexist jimexist left a 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 (_)

@jackwener
Copy link
Member Author

Thanks @jimexist @alamb

Copy link
Contributor

@alamb alamb left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@alamb alamb merged commit 72487cf into apache:master Aug 21, 2022
@ursabot
Copy link

ursabot commented Aug 21, 2022

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.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@jackwener jackwener deleted the refactor branch November 11, 2022 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants