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

13.0 fix: allow multiple distinct columns on single shards #10047

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions go/vt/vtgate/planbuilder/testdata/aggr_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3116,3 +3116,25 @@ Gen4 plan same as above
]
}
}

"select count(distinct user_id, name) from unsharded"
{
"QueryType": "SELECT",
"Original": "select count(distinct user_id, name) from unsharded",
"Instructions": {
"OperatorType": "Route",
"Variant": "Unsharded",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"FieldQuery": "select count(distinct user_id, `name`) from unsharded where 1 != 1",
"Query": "select count(distinct user_id, `name`) from unsharded",
"Table": "unsharded"
}
}
Gen4 plan same as above

"select count(distinct user_id, name) from user"
"unsupported: only one expression allowed inside aggregates: count(distinct user_id, `name`)"
Gen4 error: aggregate functions take a single argument 'count(distinct user_id, `name`)'
2 changes: 1 addition & 1 deletion go/vt/vtgate/semantics/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (a *analyzer) checkForInvalidConstructs(cursor *sqlparser.Cursor) error {

if node.Distinct {
err := vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "syntax error: %s", sqlparser.String(node))
if len(node.Exprs) != 1 {
if len(node.Exprs) < 1 {
return err
} else if _, ok := node.Exprs[0].(*sqlparser.AliasedExpr); !ok {
return err
Expand Down