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/11/16 13:08:28 UTC

[GitHub] [arrow-datafusion] Ted-Jiang opened a new pull request, #4242: Support binary boolean operators with nulls

Ted-Jiang opened a new pull request, #4242:
URL: https://github.com/apache/arrow-datafusion/pull/4242

   Signed-off-by: yangjiang <ya...@ebay.com>
   
   # 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.
   -->
   
   Closes #4241.
   
   # Rationale for this change
   
   in spark:
   ```
   spark-sql> select null or true;
   true
   Time taken: 0.65 seconds, Fetched 1 row(s)
   spark-sql> select null or false;
   NULL
   Time taken: 0.076 seconds, Fetched 1 row(s)
   ```
   in pg:
   ```
   postgres=# select true or NULL test;
    test
   ------
    t
   (1 row)
   
   postgres=# select false or NULL test;
    test
   ------
   
   (1 row)
   ```
   After this change in datafusion
   ```
   ❯ select NULL or false;
   +------------------------+
   | NULL OR Boolean(false) |
   +------------------------+
   |                        |
   +------------------------+
   1 row in set. Query took 0.067 seconds.
   ❯ select NULL or true;
   +-----------------------+
   | NULL OR Boolean(true) |
   +-----------------------+
   | true                  |
   +-----------------------+
   1 row in set. Query took 0.003 seconds.
   ```
   Also test with `AND` 
   
   # What changes are included in this PR?
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # 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] jackwener commented on a diff in pull request #4242: Support binary boolean operators with nulls

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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -98,8 +98,12 @@ pub fn coerce_types(
         | Operator::BitwiseShiftRight
         | Operator::BitwiseShiftLeft => bitwise_coercion(lhs_type, rhs_type),
         Operator::And | Operator::Or => match (lhs_type, rhs_type) {
-            // logical binary boolean operators can only be evaluated in bools
+            // logical binary boolean operators can only be evaluated in bools or nulls
             (DataType::Boolean, DataType::Boolean) => Some(DataType::Boolean),
+            (DataType::Null, DataType::Null) => Some(DataType::Null),
+            (DataType::Boolean, DataType::Null) | (DataType::Null, DataType::Boolean) => {
+                Some(DataType::Boolean)

Review Comment:
   Here exist some problem.
   true And Null -> Null
   false Or Null -> Null



-- 
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 #4242: Support binary boolean operators with nulls

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

   Benchmark runs are scheduled for baseline = 905935cf2eb90130c340d0a6512f66189319139e and contender = b935cff812418df3096a552eeaa3fddf2193d2ff. b935cff812418df3096a552eeaa3fddf2193d2ff 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/a1663da84ed34d42aad008947e2b34ab...172565104d54404f9941f367af0cc29e/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/554dbc5bb0764962b10cec6f98bbcaf6...0dd8a7f82aef46da9ce4f38433e4f031/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/03f5954cd78e443e88710bb180902392...701493cee1a64c678b411341fbdfa3ef/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/b25615fc0fe84494a193d8469df04b26...e3e615f33e6d45a7b7994f0eaea7b073/)
   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] alamb commented on a diff in pull request #4242: Support binary boolean operators with nulls

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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -98,8 +98,12 @@ pub fn coerce_types(
         | Operator::BitwiseShiftRight
         | Operator::BitwiseShiftLeft => bitwise_coercion(lhs_type, rhs_type),
         Operator::And | Operator::Or => match (lhs_type, rhs_type) {
-            // logical binary boolean operators can only be evaluated in bools
+            // logical binary boolean operators can only be evaluated in bools or nulls
             (DataType::Boolean, DataType::Boolean) => Some(DataType::Boolean),
+            (DataType::Null, DataType::Null) => Some(DataType::Null),

Review Comment:
   👍 



-- 
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] Ted-Jiang commented on a diff in pull request #4242: Support binary boolean operators with nulls

Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on code in PR #4242:
URL: https://github.com/apache/arrow-datafusion/pull/4242#discussion_r1024100731


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -1022,6 +1026,30 @@ mod tests {
             Operator::Or,
             DataType::Boolean
         );
+        test_coercion_binary_rule!(
+            DataType::Boolean,
+            DataType::Null,
+            Operator::And,
+            DataType::Boolean
+        );

Review Comment:
   Thanks fix in [add ut](https://github.com/apache/arrow-datafusion/pull/4242/commits/58520a9edefe8a017cba02798d28dbb9af26c068)



-- 
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] isidentical commented on a diff in pull request #4242: Support binary boolean operators with nulls

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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -1022,6 +1026,30 @@ mod tests {
             Operator::Or,
             DataType::Boolean
         );
+        test_coercion_binary_rule!(
+            DataType::Boolean,
+            DataType::Null,
+            Operator::And,
+            DataType::Boolean
+        );

Review Comment:
   I guess it makes sense to also add the last 2 combinations (`null and $bool` & `null or $bool`)
   ```rs
   test_coercion_binary_rule!(
           DataType::Null,
           DataType::Boolean,
           Operator::And,
           DataType::Boolean
   );
   test_coercion_binary_rule!(
           DataType::Null,
           DataType::Boolean,
           Operator::Or,
           DataType::Boolean
   );
   ```



-- 
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] jackwener commented on a diff in pull request #4242: Support binary boolean operators with nulls

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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -98,8 +98,12 @@ pub fn coerce_types(
         | Operator::BitwiseShiftRight
         | Operator::BitwiseShiftLeft => bitwise_coercion(lhs_type, rhs_type),
         Operator::And | Operator::Or => match (lhs_type, rhs_type) {
-            // logical binary boolean operators can only be evaluated in bools
+            // logical binary boolean operators can only be evaluated in bools or nulls
             (DataType::Boolean, DataType::Boolean) => Some(DataType::Boolean),
+            (DataType::Null, DataType::Null) => Some(DataType::Null),
+            (DataType::Boolean, DataType::Null) | (DataType::Null, DataType::Boolean) => {
+                Some(DataType::Boolean)

Review Comment:
   Here exist some problem.
   true And Null -> Null
   false Or Null -> Null



-- 
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 merged pull request #4242: Support binary boolean operators with nulls

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


-- 
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