You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/14 16:57:02 UTC

[GitHub] [arrow-datafusion] b41sh opened a new pull request, #3836: Refactor `Expr::Like`, `Expr::ILike`, `Expr::SimilarTo` to use a struct

b41sh opened a new pull request, #3836:
URL: https://github.com/apache/arrow-datafusion/pull/3836

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Part of #2175
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Refactor `Expr::Like`, `Expr::ILike`, `Expr::SimilarTo` to use a struct
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #3836: Refactor `Expr::Like`, `Expr::ILike`, `Expr::SimilarTo` to use a struct

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3836:
URL: https://github.com/apache/arrow-datafusion/pull/3836#discussion_r996290475


##########
datafusion/expr/src/expr.rs:
##########
@@ -101,26 +101,11 @@ pub enum Expr {
         right: Box<Expr>,
     },
     /// LIKE expression
-    Like {
-        negated: bool,
-        expr: Box<Expr>,
-        pattern: Box<Expr>,
-        escape_char: Option<char>,
-    },
+    Like(Like),

Review Comment:
   That is a nice reduction in replication 👍 



##########
datafusion/expr/src/expr.rs:
##########
@@ -580,39 +591,24 @@ impl Not for Expr {
 
     fn not(self) -> Self::Output {
         match self {
-            Expr::Like {
-                negated,
-                expr,
-                pattern,
-                escape_char,
-            } => Expr::Like {
-                negated: !negated,
-                expr,
-                pattern,
-                escape_char,
-            },
-            Expr::ILike {
-                negated,
-                expr,
-                pattern,
-                escape_char,
-            } => Expr::ILike {
-                negated: !negated,
-                expr,
-                pattern,
-                escape_char,
-            },
-            Expr::SimilarTo {
-                negated,
-                expr,
-                pattern,
-                escape_char,
-            } => Expr::SimilarTo {
-                negated: !negated,
-                expr,
-                pattern,
-                escape_char,
-            },
+            Expr::Like(like) => Expr::Like(Like::new(
+                !like.negated,
+                like.expr,
+                like.pattern,
+                like.escape_char,
+            )),

Review Comment:
   Another way you can write this type of match is like 
   
   ```suggestion
               Expr::Like(Like { negated, expr, pattern, escape_char} ) => Expr::Like(Like::new(
                   negated,
                   expr,
                   pattern,
                   escape_char,
               )),
   ```
   
   The benefit of doing so is that if any new field is added to `Like` the compiler will force you to update all places that use `Like` to add the new field where as this way you would have to find them manually
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] ursabot commented on pull request #3836: Refactor `Expr::Like`, `Expr::ILike`, `Expr::SimilarTo` to use a struct

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3836:
URL: https://github.com/apache/arrow-datafusion/pull/3836#issuecomment-1279827528

   Benchmark runs are scheduled for baseline = fe0000e6de4f1a2e7e7fd1b0d75ef32f4b61f194 and contender = 17d02177bbf00a05a7f785f960c24d45adbda8b9. 17d02177bbf00a05a7f785f960c24d45adbda8b9 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/33f5536786274fd99d1beb5b95c2d908...02548ce0c82a4dcb8ea7dd4d7d6edf6c/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/3b3b17762f8a4d64867bdc85841b8914...4b7dd7043da14a3aa76ad171d61434f1/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/fd0f985ba73d482e9c8e9d03da558bec...8d1c02d3bfa04272b0374af57871a792/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/c28bf333950d43b2bc3d157057956386...0e780b4830ea42b280a65d32e5dd17c4/)
   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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] andygrove commented on pull request #3836: Refactor `Expr::Like`, `Expr::ILike`, `Expr::SimilarTo` to use a struct

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #3836:
URL: https://github.com/apache/arrow-datafusion/pull/3836#issuecomment-1279826021

   Thanks @b41sh!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] andygrove merged pull request #3836: Refactor `Expr::Like`, `Expr::ILike`, `Expr::SimilarTo` to use a struct

Posted by GitBox <gi...@apache.org>.
andygrove merged PR #3836:
URL: https://github.com/apache/arrow-datafusion/pull/3836


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org