alamb commented on code in PR #2810:
URL: https://github.com/apache/arrow-datafusion/pull/2810#discussion_r910509404
##########
datafusion/physical-expr/src/expressions/case.rs:
##########
@@ -138,7 +138,12 @@ impl CaseExpr {
let then_value = self.when_then_expr[i]
.1
.evaluate_selection(batch, &when_match)?;
- let then_value = then_value.into_array(batch.num_rows());
+ let then_value = match then_value {
+ ColumnarValue::Scalar(value) if value.is_null() => {
+ new_null_array(&return_type, batch.num_rows())
+ }
Review Comment:
Update: I removed it and the tests errored 🤣
```
---- sql::expr::case_expr_with_null stdout ----
thread 'sql::expr::case_expr_with_null' panicked at 'called
`Result::unwrap()` on an `Err` value:
"ArrowError(InvalidArgumentError(\"arguments need to have the same data
type\")) at Executing physical plan for 'select case when b is null then null
else b end from (select a,b from (values (1,null),(2,3)) as t (a,b)) a;':
ProjectionExec { expr: [(CaseExpr { expr: None, when_then_expr: [(IsNullExpr {
arg: Column { name: \"b\", index: 0 } }, Literal { value: NULL })], else_expr:
Some(Column { name: \"b\", index: 0 }) }, \"CASE WHEN #a.b IS NULL THEN NULL
ELSE #a.b END\")], schema: Schema { fields: [Field { name: \"CASE WHEN #a.b IS
NULL THEN NULL ELSE #a.b END\", data_type: Int64, nullable: true, dict_id: 0,
dict_is_ordered: false, metadata: None }], metadata: {} }, input:
ProjectionExec { expr: [(Column { name: \"b\", index: 0 }, \"b\")], schema:
Schema { fields: [Field { name: \"b\", data_type: Int64, nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: None }], metadata: {
} }, input: ProjectionExec { expr: [(Column { name: \"b\", index: 0 },
\"b\")], schema: Schema { fields: [Field { name: \"b\", data_type: Int64,
nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }],
metadata: {} }, input: ProjectionExec { expr: [(Column { name: \"column2\",
index: 0 }, \"b\")], schema: Schema { fields: [Field { name: \"b\", data_type:
Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }],
metadata: {} }, input: ProjectionExec { expr: [(Column { name: \"column2\",
index: 1 }, \"column2\")], schema: Schema { fields: [Field { name: \"column2\",
data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
None }], metadata: {} }, input: ValuesExec { schema: Schema { fields: [Field {
name: \"column1\", data_type: Int64, nullable: true, dict_id: 0,
dict_is_ordered: false, metadata: None }, Field { name: \"column2\", data_type:
Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: None }],
metadata:
{} }, data: [RecordBatch { schema: Schema { fields: [Field { name:
\"column1\", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered:
false, metadata: None }, Field { name: \"column2\", data_type: Int64, nullable:
true, dict_id: 0, dict_is_ordered: false, metadata: None }], metadata: {} },
columns: [PrimitiveArray<Int64>\n[\n 1,\n 2,\n], PrimitiveArray<Int64>\n[\n
null,\n 3,\n]], row_count: 2 }] }, metrics: ExecutionPlanMetricsSet { inner:
Mutex { data: MetricsSet { metrics: [] } } } }, metrics:
ExecutionPlanMetricsSet { inner: Mutex { data: MetricsSet { metrics: [] } } }
}, metrics: ExecutionPlanMetricsSet { inner: Mutex { data: MetricsSet {
metrics: [] } } } }, metrics: ExecutionPlanMetricsSet { inner: Mutex { data:
MetricsSet { metrics: [] } } } }, metrics: ExecutionPlanMetricsSet { inner:
Mutex { data: MetricsSet { metrics: [] } } } }"',
datafusion/core/tests/sql/mod.rs:641:10
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]