@@ -18,8 +18,6 @@ import (
1818 "fmt"
1919 "strings"
2020
21- "github.com/dolthub/go-mysql-server/sql/expression/function/aggregation"
22-
2321 "github.com/dolthub/go-mysql-server/sql"
2422 "github.com/dolthub/go-mysql-server/sql/expression"
2523 "github.com/dolthub/go-mysql-server/sql/plan"
@@ -583,19 +581,18 @@ func (s *idxScope) visitSelf(n sql.Node) error {
583581 // default nodes can't see lateral join nodes, unless we're in lateral
584582 // join and lateral scopes are promoted to parent status
585583 for _ , e := range ne .Expressions () {
586- // groupConcat is special as it appends results to outer scope row
587- // we need to account for this extra column in the rows when assigning indexes
588- // see gms/expression/function/aggregation/group_concat.go:groupConcatBuffer.Update()
589- if gc , isGc := e .(* aggregation. GroupConcat ); isGc {
590- selExprs := gc . GetSelectExprs ()
584+ // OrderedAggregations are special as they append results to the outer scope row
585+ // We need to account for this extra column in the rows when assigning indexes
586+ // Example: gms/expression/function/aggregation/group_concat.go:groupConcatBuffer.Update()
587+ if ordAgg , isOrdAgg := e .(sql. OrderedAggregation ); isOrdAgg {
588+ selExprs := ordAgg . OutputExpressions ()
591589 selScope := & idxScope {}
592590 for _ , expr := range selExprs {
593591 selScope .columns = append (selScope .columns , expr .String ())
594592 if gf , isGf := expr .(* expression.GetField ); isGf {
595593 selScope .ids = append (selScope .ids , gf .Id ())
596594 }
597595 }
598- scope = append (scope , selScope )
599596 }
600597 s .expressions = append (s .expressions , fixExprToScope (e , scope ... ))
601598 }
0 commit comments