Skip to content

Commit 26ebbb8

Browse files
committed
bugfix: don't use derived table twice
Signed-off-by: Andres Taylor <andres@planetscale.com>
1 parent 9c20c16 commit 26ebbb8

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

go/vt/vtgate/planbuilder/operators/horizon_expanding.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ outer:
300300
func createProjectionForComplexAggregation(a *Aggregator, qp *QueryProjection) Operator {
301301
p := newAliasedProjection(a)
302302
p.DT = a.DT
303+
a.DT = nil // we don't need the derived table twice
303304
for _, expr := range qp.SelectExprs {
304305
ae, err := expr.GetAliasedExpr()
305306
if err != nil {

go/vt/vtgate/planbuilder/testdata/aggr_cases.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@
590590
"Sharded": true
591591
},
592592
"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",
593-
"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",
593+
"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",
594594
"Table": "`user`"
595595
}
596596
]
@@ -3644,10 +3644,9 @@
36443644
"Original": "select * from (select id from user having count(*) = 1) s",
36453645
"Instructions": {
36463646
"OperatorType": "SimpleProjection",
3647-
"ColumnNames": [
3648-
"0:id"
3647+
"Columns": [
3648+
0
36493649
],
3650-
"Columns": "0",
36513650
"Inputs": [
36523651
{
36533652
"OperatorType": "Projection",
@@ -6594,11 +6593,11 @@
65946593
{
65956594
"OperatorType": "SimpleProjection",
65966595
"Columns": [
6597-
2,
6598-
0,
6599-
1,
6600-
3
6601-
],
6596+
2,
6597+
0,
6598+
1,
6599+
3
6600+
],
66026601
"Inputs": [
66036602
{
66046603
"OperatorType": "Sort",

go/vt/vtgate/planbuilder/testdata/cte_cases.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,9 @@
370370
"Original": "with s as (select id from user having count(*) = 1) select * from s",
371371
"Instructions": {
372372
"OperatorType": "SimpleProjection",
373-
"ColumnNames": [
374-
"0:id"
373+
"Columns": [
374+
0
375375
],
376-
"Columns": "0",
377376
"Inputs": [
378377
{
379378
"OperatorType": "Projection",

0 commit comments

Comments
 (0)