-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression: query error with case when as the group field #11118
Comments
It seems that the projection expression lacks a whitespace between |
It might be related to #10088, and could be due to the gap between Changing the Expr::Case(case) => {
let mut name = "CASE ".to_string();
if let Some(e) = &case.expr {
let _ = write!(name, "{} ", create_physical_name(e, false)?);
}
for (w, t) in &case.when_then_expr {
let _ = write!(
name,
"WHEN {} THEN {} ",
create_physical_name(w, false)?,
create_physical_name(t, false)?
);
}
if let Some(e) = &case.else_expr {
let _ = write!(name, "ELSE {} ", create_physical_name(e, false)?);
}
name += "END";
Ok(name)
} but I'm not sure if this is the correct way to do it. Keeping these two names consistent does not seem like a good design. |
The error originates from the following check between input field names and projection expressions. It seems like failure is the expected behavior. Before v38 the mismatch was being silently ignored. But now they are being detected. datafusion/datafusion/physical-expr/src/equivalence/projection.rs Lines 70 to 73 in b21bf9e
The use of any scalar function inside select (case when ends_with(b, 'hello') THEN 'good' else 'bad' END) as c from t group by c;
Internal error: Input field name
CASE WHEN ends_with(t.b, Utf8("hello")) THEN Utf8("good") ELSE Utf8("bad") END
does not match with the projection expression
CASE WHEN ends_with(t.b,Utf8("hello")) THEN Utf8("good") ELSE Utf8("bad") END. There exists a formatting mismatch in implementations,
This is a recent issue which reports the same bug and proposes to fix it by standardizing the separator in |
A failed query that does not involve separators. > create table t(a int, b text);
0 row(s) fetched.
Elapsed 0.005 seconds.
> select (case a::bigint when 1 THEN 1 END) as c from t group by c;
Internal error: Input field name CASE CAST(t.a AS Int64) WHEN Int64(1) THEN Int64(1) END does not match with the projection expression CASE t.a WHEN Int64(1) THEN Int64(1) 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 I think having multiple different types of names for expressions, while also ensuring they are the same, seems somewhat burdensome and error-prone.🤔 |
Let's close it for this case. I'll open a new issue if there are new findings. |
Describe the bug
To Reproduce
Expected behavior
run success
Additional context
I also check in v37 and v38
v37 can run, but v38 report error
The text was updated successfully, but these errors were encountered: