Skip to content

regression: query error with case when as the group field #11118

@haohuaijin

Description

@haohuaijin

Describe the bug

Internal error: Input field name CASE WHEN concat(t.b, Utf8("hello")) = Utf8("test") THEN Utf8("good") ELSE Utf8("bad") END does not match with the projection expression CASE WHEN concat(t.b,Utf8("hello")) = Utf8("test") THEN Utf8("good") ELSE Utf8("bad") END.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

To Reproduce

DataFusion CLI v39.0.0
> create table t(a int, b text);
0 row(s) fetched.
Elapsed 0.019 seconds.

> insert into t values (1,'hello'), (2,'world');
+-------+
| count |
+-------+
| 2     |
+-------+
1 row(s) fetched.
Elapsed 0.019 seconds.

> select (case when concat(b, 'hello') = 'test' THEN 'good' else 'bad' END) as c from t group by c;
Internal error: Input field name CASE WHEN concat(t.b, Utf8("hello")) = Utf8("test") THEN Utf8("good") ELSE Utf8("bad") END does not match with the projection expression CASE WHEN concat(t.b,Utf8("hello")) = Utf8("test") THEN Utf8("good") ELSE Utf8("bad") END.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

Expected behavior

run success

Additional context

I also check in v37 and v38

v37 can run, but v38 report error

DataFusion CLI v37.0.0
❯ create table t(a int, b text);
insert into t values (1,'hello'), (2,'world');
select (case when concat(b, 'hello') = 'test' THEN 'good' else 'bad' END) as c from t group by c;
0 rows in set. Query took 0.006 seconds.

+-------+
| count |
+-------+
| 2     |
+-------+
1 row in set. Query took 0.014 seconds.

+-----+
| c   |
+-----+
| bad |
+-----+
1 row in set. Query took 0.020 seconds.
DataFusion CLI v38.0.0
> create table t(a int, b text);
insert into t values (1,'hello'), (2,'world');
select (case when concat(b, 'hello') = 'test' THEN 'good' else 'bad' END) as c from t group by c;
0 row(s) fetched.
Elapsed 0.008 seconds.

+-------+
| count |
+-------+
| 2     |
+-------+
1 row(s) fetched.
Elapsed 0.007 seconds.

Internal error: Input field name CASE WHEN concat(t.b, Utf8("hello")) = Utf8("test") THEN Utf8("good") ELSE Utf8("bad") END does not match with the projection expression CASE WHEN concat(t.b,Utf8("hello")) = Utf8("test") THEN Utf8("good") ELSE Utf8("bad") END.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions