Skip to content

Commit

Permalink
Remove SelectExprs
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Feb 4, 2025
1 parent 603df0f commit e24d767
Show file tree
Hide file tree
Showing 38 changed files with 119 additions and 253 deletions.
2 changes: 1 addition & 1 deletion go/test/endtoend/vtgate/queries/random/query_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (sg *selectGenerator) aliasGroupingColumns(grouping []column) []column {
return grouping
}

// returns the aggregation columns as three types: *sqlparser.SelectExprs2, []column
// returns the aggregation columns as three types: *sqlparser.SelectExprs, []column
func (sg *selectGenerator) createAggregations(tables []tableT) (aggregates []column) {
exprGenerators := slice.Map(tables, func(t tableT) sqlparser.ExprGenerator { return &t })
// add scalar subqueries
Expand Down
9 changes: 3 additions & 6 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type (

ColumnResults interface {
GetColumnCount() int
GetColumns() *SelectExprs2
GetColumns() *SelectExprs
}

Withable interface {
Expand Down Expand Up @@ -295,7 +295,7 @@ type (
With *With
From []TableExpr
Comments *ParsedComments
SelectExprs *SelectExprs2
SelectExprs *SelectExprs
Where *Where
GroupBy *GroupBy
Having *Where
Expand Down Expand Up @@ -2039,10 +2039,7 @@ type ParsedComments struct {
_directives *CommentDirectives
}

// SelectExprs represents SELECT expressions.
type SelectExprs []SelectExpr

type SelectExprs2 struct {
type SelectExprs struct {
Exprs []SelectExpr
}

Expand Down
24 changes: 5 additions & 19 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 5 additions & 30 deletions go/vt/sqlparser/ast_copy_on_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 6 additions & 25 deletions go/vt/sqlparser/ast_equals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -1155,16 +1155,7 @@ func (node *ParsedComments) Format(buf *TrackedBuffer) {
}

// Format formats the node.
func (node SelectExprs) Format(buf *TrackedBuffer) {
var prefix string
for _, n := range node {
buf.astPrintf(node, "%s%v", prefix, n)
prefix = ", "
}
}

// Format formats the node.
func (node *SelectExprs2) Format(buf *TrackedBuffer) {
func (node *SelectExprs) Format(buf *TrackedBuffer) {
var prefix string
for _, n := range node.Exprs {
buf.astPrintf(node, "%s%v", prefix, n)
Expand Down
12 changes: 1 addition & 11 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ func NewLimitWithoutOffset(rowCount int) *Limit {
// NewSelect is used to create a select statement
func NewSelect(
comments Comments,
exprs *SelectExprs2,
exprs *SelectExprs,
selectOptions []string,
into *SelectInto,
from TableExprs,
Expand Down Expand Up @@ -1195,16 +1195,16 @@ func compliantName(in string) string {
return buf.String()
}

func (node *Select) AddSelectExprs(selectExprs *SelectExprs2) {
func (node *Select) AddSelectExprs(selectExprs *SelectExprs) {
if node.SelectExprs == nil {
node.SelectExprs = &SelectExprs2{}
node.SelectExprs = &SelectExprs{}
}
node.SelectExprs.Exprs = append(node.SelectExprs.Exprs, selectExprs.Exprs...)
}

func (node *Select) AddSelectExpr(expr SelectExpr) {
if node.SelectExprs == nil {
node.SelectExprs = &SelectExprs2{}
node.SelectExprs = &SelectExprs{}
}
node.SelectExprs.Exprs = append(node.SelectExprs.Exprs, expr)
}
Expand Down Expand Up @@ -1270,7 +1270,7 @@ func (node *Select) GetColumnCount() int {
}

// GetColumns gets the columns
func (node *Select) GetColumns() *SelectExprs2 {
func (node *Select) GetColumns() *SelectExprs {
return node.SelectExprs
}

Expand Down Expand Up @@ -1372,7 +1372,7 @@ func (node *Union) GetLimit() *Limit {
}

// GetColumns gets the columns
func (node *Union) GetColumns() *SelectExprs2 {
func (node *Union) GetColumns() *SelectExprs {
return node.Left.GetColumns()
}

Expand Down Expand Up @@ -2420,7 +2420,7 @@ func (ae *AliasedExpr) ColumnName() string {
}

// AllAggregation returns true if all the expressions contain aggregation
func (s *SelectExprs2) AllAggregation() bool {
func (s *SelectExprs) AllAggregation() bool {
for _, k := range s.Exprs {
if !ContainsAggregation(k) {
return false
Expand Down Expand Up @@ -3063,8 +3063,8 @@ func (node *ValuesStatement) GetColumnCount() int {
panic("no columns available") // TODO: we need a better solution than a panic
}

func (node *ValuesStatement) GetColumns() *SelectExprs2 {
sel := new(SelectExprs2)
func (node *ValuesStatement) GetColumns() *SelectExprs {
sel := new(SelectExprs)
columnCount := node.GetColumnCount()
for i := range columnCount {
sel.Exprs = append(sel.Exprs, &AliasedExpr{Expr: NewColName(fmt.Sprintf("column_%d", i))})
Expand Down
50 changes: 6 additions & 44 deletions go/vt/sqlparser/ast_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e24d767

Please sign in to comment.