-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Planner inferred wrong return type for firstrow agg function #34584
Labels
affects-5.0
This bug affects 5.0.x versions.
affects-5.1
This bug affects 5.1.x versions.
affects-5.2
This bug affects 5.2.x versions.
affects-5.3
This bug affects 5.3.x versions.
affects-5.4
This bug affects the 5.4.x(LTS) versions.
affects-6.0
affects-6.1
This bug affects the 6.1.x(LTS) versions.
severity/major
sig/planner
SIG: Planner
type/bug
The issue is confirmed as a bug.
Comments
See also pingcap/tiflash#4556 |
Merged
12 tasks
seiya-annie
added
sig/planner
SIG: Planner
severity/major
and removed
sig/planner
SIG: Planner
labels
May 12, 2022
ti-chi-bot
added
may-affects-4.0
This bug maybe affects 4.0.x versions.
may-affects-5.0
This bug maybe affects 5.0.x versions.
may-affects-5.1
This bug maybe affects 5.1.x versions.
may-affects-5.2
This bug maybe affects 5.2.x versions.
may-affects-5.3
This bug maybe affects 5.3.x versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.0
labels
May 12, 2022
fixdb
added a commit
to fixdb/tidb
that referenced
this issue
May 28, 2022
…QAll special case Before this patch, the fisrtrow agg function infer the return type same with the argument data type, which is wrong when the arg is not null during the process planner decorrelate EQAll subqueries, and may cause error on TiFlash engine. Currently, firstrow agg function is treated like the exact representation of aggregate group key, so the data type is the same with group key, even if the group key is not null. However, the return type of firstrow should be nullable, we clear the null flag here instead of during invoking NewAggFuncDesc, in order to keep compatibility with the existing presumption that the return type firstrow does not change nullability, whatsoever. This also can be testified by commit ad7102c, in which it stated that: ``` For all the aggregate functions except `first_row`, if we have an empty table defined as t(a,b), `select agg(a) from t` would always return one row, while `select agg(a) from t group by b` would return empty. For `first_row` which is only used internally by tidb, `first_row(a)` would always return empty for empty input now. ``` Close pingcap#34584
qw4990
added
affects-5.0
This bug affects 5.0.x versions.
affects-5.1
This bug affects 5.1.x versions.
and removed
may-affects-4.0
This bug maybe affects 4.0.x versions.
may-affects-5.1
This bug maybe affects 5.1.x versions.
may-affects-5.2
This bug maybe affects 5.2.x versions.
may-affects-5.3
This bug maybe affects 5.3.x versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-5.0
This bug maybe affects 5.0.x versions.
labels
May 30, 2022
qw4990
added
affects-5.2
This bug affects 5.2.x versions.
affects-5.3
This bug affects 5.3.x versions.
affects-5.4
This bug affects the 5.4.x(LTS) versions.
affects-6.0
and removed
may-affects-6.0
labels
May 30, 2022
This was referenced May 30, 2022
This was referenced Aug 29, 2022
This was referenced Sep 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
affects-5.0
This bug affects 5.0.x versions.
affects-5.1
This bug affects 5.1.x versions.
affects-5.2
This bug affects 5.2.x versions.
affects-5.3
This bug affects 5.3.x versions.
affects-5.4
This bug affects the 5.4.x(LTS) versions.
affects-6.0
affects-6.1
This bug affects the 6.1.x(LTS) versions.
severity/major
sig/planner
SIG: Planner
type/bug
The issue is confirmed as a bug.
Smaller repo:
But in Tikv, it is getting expected result, same with MySQL:
The text was updated successfully, but these errors were encountered: