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/11 04:21:23 UTC

[GitHub] [arrow-datafusion] yjshen commented on a diff in pull request #2197: `case when` supports `NULL` constant

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