From 0c2831f04e8f8be38785cd9b135df1c6c33b9574 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Thu, 17 Oct 2024 09:48:41 +0200 Subject: [PATCH] bugfix: don't use derived table twice Signed-off-by: Andres Taylor --- .../planbuilder/operators/horizon_expanding.go | 1 + go/vt/vtgate/planbuilder/testdata/aggr_cases.json | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go/vt/vtgate/planbuilder/operators/horizon_expanding.go b/go/vt/vtgate/planbuilder/operators/horizon_expanding.go index bf7e95f5a17..59892bc13da 100644 --- a/go/vt/vtgate/planbuilder/operators/horizon_expanding.go +++ b/go/vt/vtgate/planbuilder/operators/horizon_expanding.go @@ -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 { diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.json b/go/vt/vtgate/planbuilder/testdata/aggr_cases.json index bf12cd7b884..c01590d6da4 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.json @@ -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", @@ -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`" } ] @@ -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": [ {