From 4f41e440e06f368c144e7d3e7f20dd7c608e1378 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Wed, 12 Jun 2024 14:41:16 +0200 Subject: [PATCH] refactor: move methods Signed-off-by: Andres Taylor --- .../vtgate/queries/subquery/queries.txt | 0 go/vt/sqlparser/ast.go | 26 +++++++++ go/vt/sqlparser/ast_funcs.go | 57 ------------------- 3 files changed, 26 insertions(+), 57 deletions(-) create mode 100644 go/test/endtoend/vtgate/queries/subquery/queries.txt diff --git a/go/test/endtoend/vtgate/queries/subquery/queries.txt b/go/test/endtoend/vtgate/queries/subquery/queries.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/go/vt/sqlparser/ast.go b/go/vt/sqlparser/ast.go index bef25a00fdd..76beb368943 100644 --- a/go/vt/sqlparser/ast.go +++ b/go/vt/sqlparser/ast.go @@ -3426,6 +3426,32 @@ func (varS *VarSamp) SetArg(expr Expr) { varS.Arg = expr } func (variance *Variance) SetArg(expr Expr) { variance.Arg = expr } func (av *AnyValue) SetArg(expr Expr) { av.Arg = expr } +func (min *Min) SetArgs(exprs Exprs) error { return setFuncArgs(min, exprs, "MIN") } +func (sum *Sum) SetArgs(exprs Exprs) error { return setFuncArgs(sum, exprs, "SUM") } +func (max *Max) SetArgs(exprs Exprs) error { return setFuncArgs(max, exprs, "MAX") } +func (avg *Avg) SetArgs(exprs Exprs) error { return setFuncArgs(avg, exprs, "AVG") } +func (*CountStar) SetArgs(Exprs) error { return nil } +func (bAnd *BitAnd) SetArgs(exprs Exprs) error { return setFuncArgs(bAnd, exprs, "BIT_AND") } +func (bOr *BitOr) SetArgs(exprs Exprs) error { return setFuncArgs(bOr, exprs, "BIT_OR") } +func (bXor *BitXor) SetArgs(exprs Exprs) error { return setFuncArgs(bXor, exprs, "BIT_XOR") } +func (std *Std) SetArgs(exprs Exprs) error { return setFuncArgs(std, exprs, "STD") } +func (stdD *StdDev) SetArgs(exprs Exprs) error { return setFuncArgs(stdD, exprs, "STDDEV") } +func (stdP *StdPop) SetArgs(exprs Exprs) error { return setFuncArgs(stdP, exprs, "STDDEV_POP") } +func (stdS *StdSamp) SetArgs(exprs Exprs) error { return setFuncArgs(stdS, exprs, "STDDEV_SAMP") } +func (varP *VarPop) SetArgs(exprs Exprs) error { return setFuncArgs(varP, exprs, "VAR_POP") } +func (varS *VarSamp) SetArgs(exprs Exprs) error { return setFuncArgs(varS, exprs, "VAR_SAMP") } +func (variance *Variance) SetArgs(exprs Exprs) error { return setFuncArgs(variance, exprs, "VARIANCE") } +func (av *AnyValue) SetArgs(exprs Exprs) error { return setFuncArgs(av, exprs, "ANY_VALUE") } + +func (count *Count) SetArgs(exprs Exprs) error { + count.Args = exprs + return nil +} +func (grpConcat *GroupConcatExpr) SetArgs(exprs Exprs) error { + grpConcat.Exprs = exprs + return nil +} + func (sum *Sum) IsDistinct() bool { return sum.Distinct } func (min *Min) IsDistinct() bool { return min.Distinct } func (max *Max) IsDistinct() bool { return max.Distinct } diff --git a/go/vt/sqlparser/ast_funcs.go b/go/vt/sqlparser/ast_funcs.go index 8ceb9d32643..f4f1e3a5455 100644 --- a/go/vt/sqlparser/ast_funcs.go +++ b/go/vt/sqlparser/ast_funcs.go @@ -2184,63 +2184,6 @@ func ContainsAggregation(e SQLNode) bool { return hasAggregates } -func (min *Min) SetArgs(exprs Exprs) error { - return setFuncArgs(min, exprs, "MIN") -} -func (sum *Sum) SetArgs(exprs Exprs) error { - return setFuncArgs(sum, exprs, "SUM") -} -func (max *Max) SetArgs(exprs Exprs) error { - return setFuncArgs(max, exprs, "MAX") -} -func (avg *Avg) SetArgs(exprs Exprs) error { - return setFuncArgs(avg, exprs, "AVG") -} -func (*CountStar) SetArgs(exprs Exprs) error { - return nil -} -func (count *Count) SetArgs(exprs Exprs) error { - count.Args = exprs - return nil -} -func (grpConcat *GroupConcatExpr) SetArgs(exprs Exprs) error { - grpConcat.Exprs = exprs - return nil -} -func (bAnd *BitAnd) SetArgs(exprs Exprs) error { - return setFuncArgs(bAnd, exprs, "BIT_AND") -} -func (bOr *BitOr) SetArgs(exprs Exprs) error { - return setFuncArgs(bOr, exprs, "BIT_OR") -} -func (bXor *BitXor) SetArgs(exprs Exprs) error { - return setFuncArgs(bXor, exprs, "BIT_XOR") -} -func (std *Std) SetArgs(exprs Exprs) error { - return setFuncArgs(std, exprs, "STD") -} -func (stdD *StdDev) SetArgs(exprs Exprs) error { - return setFuncArgs(stdD, exprs, "STDDEV") -} -func (stdP *StdPop) SetArgs(exprs Exprs) error { - return setFuncArgs(stdP, exprs, "STDDEV_POP") -} -func (stdS *StdSamp) SetArgs(exprs Exprs) error { - return setFuncArgs(stdS, exprs, "STDDEV_SAMP") -} -func (varP *VarPop) SetArgs(exprs Exprs) error { - return setFuncArgs(varP, exprs, "VAR_POP") -} -func (varS *VarSamp) SetArgs(exprs Exprs) error { - return setFuncArgs(varS, exprs, "VAR_SAMP") -} -func (variance *Variance) SetArgs(exprs Exprs) error { - return setFuncArgs(variance, exprs, "VARIANCE") -} -func (av *AnyValue) SetArgs(exprs Exprs) error { - return setFuncArgs(av, exprs, "ANY_VALUE") -} - // setFuncArgs sets the arguments for the aggregation function, while checking that there is only one argument func setFuncArgs(aggr AggrFunc, exprs Exprs, name string) error { if len(exprs) != 1 {