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/04/10 21:19:47 UTC
[GitHub] [arrow-datafusion] WinkerDu opened a new pull request, #2197: `case .. when ..` supports `NULL` constants
WinkerDu opened a new pull request, #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197
# 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 #1189.
# 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.
-->
comment later.
# 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.
-->
comment later.
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
No.
<!--
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] yjshen commented on a diff in pull request #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
yjshen commented on code in PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#discussion_r846932443
##########
datafusion/physical-expr/src/expressions/case.rs:
##########
@@ -24,7 +24,7 @@ use arrow::compute::kernels::zip::zip;
use arrow::compute::{and, eq_dyn, is_null, not, or, or_kleene};
use arrow::datatypes::{DataType, Schema};
use arrow::record_batch::RecordBatch;
-use datafusion_common::{DataFusionError, Result};
+use datafusion_common::{DataFusionError, Result, ScalarValue};
Review Comment:
```suggestion
use datafusion_common::{DataFusionError, Result};
```
--
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] WinkerDu commented on pull request #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
WinkerDu commented on PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#issuecomment-1094683082
cc @yjshen @alamb another commit pushed, PTAL, thank you.
--
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] WinkerDu commented on pull request #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
WinkerDu commented on PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#issuecomment-1094469487
cc @yjshen @Dandandan @alamb
--
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 pull request #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#issuecomment-1098027398
Thank you @WinkerDu
--
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 #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#discussion_r849312085
##########
datafusion/physical-expr/src/expressions/case.rs:
##########
@@ -178,6 +178,13 @@ impl CaseExpr {
let when_value = self.when_then_expr[i]
.0
.evaluate_selection(batch, &remainder)?;
+ // Treat 'NULL' as false value
+ let when_value = match when_value {
+ ColumnarValue::Scalar(value) if value.is_null() => {
Review Comment:
This is a reasonable solution I think -- ideally we would have been able to coerce this value into a `ColumnarValue::Scalar(ScalarValue::Boolean(None))` at some earlier point.
However, I think this special case is reasonable (and the test coverage is nice) so 👍 from me
--
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] yjshen commented on a diff in pull request #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
yjshen commented on code in PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#discussion_r846930183
##########
datafusion/physical-expr/src/expressions/case.rs:
##########
@@ -178,6 +178,17 @@ impl CaseExpr {
let when_value = self.when_then_expr[i]
.0
.evaluate_selection(batch, &remainder)?;
+ // Treat 'NULL' as false value
+ let when_value = match when_value {
+ ColumnarValue::Scalar(value) => {
+ if value.is_null() {
+ ColumnarValue::Scalar(ScalarValue::Boolean(Some(false)))
+ } else {
+ ColumnarValue::Scalar(value)
+ }
+ }
+ _ => when_value,
+ };
Review Comment:
```suggestion
let when_value = match when_value {
ColumnarValue::Scalar(value) if value.is_null() => {
continue;
}
_ => when_value,
};
```
--
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 #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
alamb merged PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197
--
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] WinkerDu commented on pull request #2197: `case when` supports `NULL` constant
Posted by GitBox <gi...@apache.org>.
WinkerDu commented on PR #2197:
URL: https://github.com/apache/arrow-datafusion/pull/2197#issuecomment-1098024539
@alamb @yjshen thank you both!
--
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