Skip to content

Commit

Permalink
fix: allow multiple distinct columns on single shards (#10047)
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>

Co-authored-by: Andres Taylor <[email protected]>
  • Loading branch information
frouioui and systay authored Apr 7, 2022
1 parent 4e12193 commit 8750c6f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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

0 comments on commit 8750c6f

Please sign in to comment.