Skip to content
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 in an aggregate query from release-9.0 #8855

Closed
GuptaManan100 opened this issue Sep 21, 2021 · 0 comments · Fixed by #8856
Closed

Regression in an aggregate query from release-9.0 #8855

GuptaManan100 opened this issue Sep 21, 2021 · 0 comments · Fixed by #8856

Comments

@GuptaManan100
Copy link
Member

Overview of the Issue

The following query works on release 9.0 -

select ascii(val1) as a, count(*) from aggr_test group by a

but on main the query fails with the following error -

target: ks.-80.primary: vttablet: rpc error: code = InvalidArgument desc = Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'vt_ks.aggr_test.val1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (errno 1055) (sqlstate 42000) (CallerID: userData1): Sql: "select ascii(val1) as a, count(*), weight_string(ascii(val1)) from aggr_test group by a order by a asc", BindVars: {}
target: ks.80-.primary: vttablet: rpc error: code = InvalidArgument desc = Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'vt_ks.aggr_test.val1' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (errno 1055) (sqlstate 42000) (CallerID: userData1): Sql: "select ascii(val1) as a, count(*), weight_string(ascii(val1)) from aggr_test group by a order by a asc", BindVars: {} (errno 1055) (sqlstate 42000) during query: select ascii(val1) as a, count(*) from aggr_test group by a

Schema for the table is -

create table aggr_test(
	id bigint,
	val1 varchar(16),
	val2 bigint,
	primary key(id)
) Engine=InnoDB;

Reproduction Steps

Add the query as an end to end test and run it.

Binary version

Log Fragments

@GuptaManan100 GuptaManan100 self-assigned this Sep 21, 2021
systay pushed a commit to systay/vitess that referenced this issue Sep 22, 2021
This is a backport of vitessio#8856

The regression in the linked issue was found to be occurring from adding weight_string function due to order by as introduced in vitessio#7678. MySQL however does not support the generated query -

```
select ascii(val1) as a, count(*), weight_string(ascii(val1)) from aggr_test group by a order by a asc
```

In order to fix this, we should also add the weight_string function to the group by clause as follows -

```
select ascii(val1) as a, count(*), weight_string(ascii(val1)) from aggr_test group by a, weight_string(ascii(val1)) order by a asc
```

Fixes vitessio#8855

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant