Skip to content

Commit

Permalink
bugfix: don't use derived table twice
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Oct 17, 2024
1 parent 5fc37e2 commit 0c2831f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions go/vt/vtgate/planbuilder/operators/horizon_expanding.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ outer:
func createProjectionForComplexAggregation(a *Aggregator, qp *QueryProjection) (ops.Operator, error) {
p := newAliasedProjection(a)
p.DT = a.DT
a.DT = nil // we don't need the derived table twice
for _, expr := range qp.SelectExprs {
ae, err := expr.GetAliasedExpr()
if err != nil {
Expand Down
15 changes: 7 additions & 8 deletions go/vt/vtgate/planbuilder/testdata/aggr_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@
"Original": "select id from (select id from user group by id having (count(user.id) = 2) limit 2 offset 0) subquery_for_limit",
"Instructions": {
"OperatorType": "Limit",
"Count": "2",
"Offset": "0",
"Count": "INT64(2)",
"Offset": "INT64(0)",
"Inputs": [
{
"OperatorType": "Route",
Expand All @@ -590,7 +590,7 @@
"Sharded": true
},
"FieldQuery": "select id from (select id, count(`user`.id) = 2 from `user` where 1 != 1 group by id) as subquery_for_limit where 1 != 1",
"Query": "select id from (select id, count(`user`.id) = 2 from `user` group by id having count(`user`.id) = 2) as subquery_for_limit limit 2",
"Query": "select id from (select id, count(`user`.id) = 2 from `user` group by id having count(`user`.id) = 2) as subquery_for_limit limit :__upper_limit",
"Table": "`user`"
}
]
Expand Down Expand Up @@ -3643,16 +3643,15 @@
"Original": "select * from (select id from user having count(*) = 1) s",
"Instructions": {
"OperatorType": "SimpleProjection",
"ColumnNames": [
"0:id"
"Columns": [
0
],
"Columns": "0",
"Inputs": [
{
"OperatorType": "Projection",
"Expressions": [
":0 as id",
"count(*) = 1 as count(*) = 1"
"[COLUMN 0] as id",
"[COLUMN 1] = [COLUMN 2] as count(*) = 1"
],
"Inputs": [
{
Expand Down

0 comments on commit 0c2831f

Please sign in to comment.