alamb commented on issue #14154:
URL: https://github.com/apache/datafusion/issues/14154#issuecomment-2627404261
Ok, I have a datafusion only reproducer:
```sql
create or replace table t as values
(
100, -- column1 int (so the case
isn't constant folded)
[{ 'foo': arrow_cast('baz', 'Utf8View') }], -- column2 has List of Struct
w/ Utf8View
[{ 'foo': 'bar' }], -- column3 has List of Struct
w/ Utf8
[{ 'foo': 'blarg' }] -- column4 has List of Struct
w/ Utf8
);
SELECT column2, column3, column4 FROM t;
SELECT
case
when column1 > 0 then column2
when column1 < 0 then column3
else column4
end
FROM t;
```
Fails with
> Error during planning: Failed to coerce then ([List(Field { name: "item",
data_type: Struct([Field { name: "foo", data_type: Utf8View, nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: true, dict_id:
0, dict_is_ordered: false, metadata: {} }), List(Field { name: "item",
data_type: Struct([Field { name: "foo", data_type: Utf8, nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: true, dict_id:
0, dict_is_ordered: false, metadata: {} })]) and else (Some(List(Field { name:
"item", data_type: Struct([Field { name: "foo", data_type: Utf8, nullable:
true, dict_id: 0, dict_is_ordered: false, metadata: {} }]), nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: {} }))) to common types in CASE
WHEN expression
It works with `datafusion-cli` on 43:
```shell
> SELECT
case
when column1 > 0 then column2
when column1 < 0 then column3
else column4
end
FROM t;
+-----------------------------------------------------------------------------------------------------------+
| CASE WHEN t.column1 > Int64(0) THEN t.column2 WHEN t.column1 < Int64(0)
THEN t.column3 ELSE t.column4 END |
+-----------------------------------------------------------------------------------------------------------+
| [{foo: baz}]
|
+-----------------------------------------------------------------------------------------------------------+
1 row(s) fetched.
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]