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 9c20c16 commit 26ebbb8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 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 @@ -300,6 +300,7 @@ outer:
func createProjectionForComplexAggregation(a *Aggregator, qp *QueryProjection) Operator {
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
17 changes: 8 additions & 9 deletions go/vt/vtgate/planbuilder/testdata/aggr_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -3644,10 +3644,9 @@
"Original": "select * from (select id from user having count(*) = 1) s",
"Instructions": {
"OperatorType": "SimpleProjection",
"ColumnNames": [
"0:id"
"Columns": [
0
],
"Columns": "0",
"Inputs": [
{
"OperatorType": "Projection",
Expand Down Expand Up @@ -6594,11 +6593,11 @@
{
"OperatorType": "SimpleProjection",
"Columns": [
2,
0,
1,
3
],
2,
0,
1,
3
],
"Inputs": [
{
"OperatorType": "Sort",
Expand Down
5 changes: 2 additions & 3 deletions go/vt/vtgate/planbuilder/testdata/cte_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,9 @@
"Original": "with s as (select id from user having count(*) = 1) select * from s",
"Instructions": {
"OperatorType": "SimpleProjection",
"ColumnNames": [
"0:id"
"Columns": [
0
],
"Columns": "0",
"Inputs": [
{
"OperatorType": "Projection",
Expand Down

0 comments on commit 26ebbb8

Please sign in to comment.