github.com/dolthub/go-mysql-server@v0.18.0/sql/expression/function/aggregation/unary_aggs.og.go (about)

     1  // Code generated by optgen; DO NOT EDIT.
     2  
     3  package aggregation
     4  
     5  import (
     6  	"fmt"
     7  
     8  	"github.com/dolthub/go-mysql-server/sql"
     9  	"github.com/dolthub/go-mysql-server/sql/expression"
    10  	"github.com/dolthub/go-mysql-server/sql/transform"
    11  	"github.com/dolthub/go-mysql-server/sql/types"
    12  )
    13  
    14  type AnyValue struct {
    15  	unaryAggBase
    16  }
    17  
    18  var _ sql.FunctionExpression = (*AnyValue)(nil)
    19  var _ sql.Aggregation = (*AnyValue)(nil)
    20  var _ sql.WindowAdaptableExpression = (*AnyValue)(nil)
    21  
    22  func NewAnyValue(e sql.Expression) *AnyValue {
    23  	return &AnyValue{
    24  		unaryAggBase{
    25  			UnaryExpression: expression.UnaryExpression{Child: e},
    26  			functionName:    "AnyValue",
    27  			description:     "returns any single value in the grouped rows",
    28  		},
    29  	}
    30  }
    31  
    32  func (a *AnyValue) Type() sql.Type {
    33  	return a.Child.Type()
    34  }
    35  
    36  func (a *AnyValue) IsNullable() bool {
    37  	return true
    38  }
    39  
    40  func (a *AnyValue) String() string {
    41  	if a.window != nil {
    42  		pr := sql.NewTreePrinter()
    43  		_ = pr.WriteNode("ANYVALUE")
    44  		children := []string{a.window.String(), a.Child.String()}
    45  		pr.WriteChildren(children...)
    46  		return pr.String()
    47  	}
    48  	return fmt.Sprintf("ANYVALUE(%s)", a.Child)
    49  }
    50  
    51  func (a *AnyValue) DebugString() string {
    52  	if a.window != nil {
    53  		pr := sql.NewTreePrinter()
    54  		_ = pr.WriteNode("ANYVALUE")
    55  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
    56  		pr.WriteChildren(children...)
    57  		return pr.String()
    58  	}
    59  	return fmt.Sprintf("ANYVALUE(%s)", sql.DebugString(a.Child))
    60  }
    61  
    62  func (a *AnyValue) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
    63  	res := a.unaryAggBase.WithWindow(window)
    64  	return &AnyValue{unaryAggBase: *res.(*unaryAggBase)}
    65  }
    66  
    67  func (a *AnyValue) WithChildren(children ...sql.Expression) (sql.Expression, error) {
    68  	res, err := a.unaryAggBase.WithChildren(children...)
    69  	return &AnyValue{unaryAggBase: *res.(*unaryAggBase)}, err
    70  }
    71  
    72  func (a *AnyValue) WithId(id sql.ColumnId) sql.IdExpression {
    73  	res := a.unaryAggBase.WithId(id)
    74  	return &AnyValue{unaryAggBase: *res.(*unaryAggBase)}
    75  }
    76  
    77  func (a *AnyValue) NewBuffer() (sql.AggregationBuffer, error) {
    78  	child, err := transform.Clone(a.Child)
    79  	if err != nil {
    80  		return nil, err
    81  	}
    82  	return NewAnyValueBuffer(child), nil
    83  }
    84  
    85  func (a *AnyValue) NewWindowFunction() (sql.WindowFunction, error) {
    86  	child, err := transform.Clone(a.Child)
    87  	if err != nil {
    88  		return nil, err
    89  	}
    90  	return NewAnyValueAgg(child).WithWindow(a.Window())
    91  }
    92  
    93  type Avg struct {
    94  	unaryAggBase
    95  }
    96  
    97  var _ sql.FunctionExpression = (*Avg)(nil)
    98  var _ sql.Aggregation = (*Avg)(nil)
    99  var _ sql.WindowAdaptableExpression = (*Avg)(nil)
   100  
   101  func NewAvg(e sql.Expression) *Avg {
   102  	return &Avg{
   103  		unaryAggBase{
   104  			UnaryExpression: expression.UnaryExpression{Child: e},
   105  			functionName:    "Avg",
   106  			description:     "returns the average value of expr in all rows.",
   107  		},
   108  	}
   109  }
   110  
   111  func (a *Avg) Type() sql.Type {
   112  	return a.Child.Type()
   113  }
   114  
   115  func (a *Avg) IsNullable() bool {
   116  	return true
   117  }
   118  
   119  func (a *Avg) String() string {
   120  	if a.window != nil {
   121  		pr := sql.NewTreePrinter()
   122  		_ = pr.WriteNode("AVG")
   123  		children := []string{a.window.String(), a.Child.String()}
   124  		pr.WriteChildren(children...)
   125  		return pr.String()
   126  	}
   127  	return fmt.Sprintf("AVG(%s)", a.Child)
   128  }
   129  
   130  func (a *Avg) DebugString() string {
   131  	if a.window != nil {
   132  		pr := sql.NewTreePrinter()
   133  		_ = pr.WriteNode("AVG")
   134  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   135  		pr.WriteChildren(children...)
   136  		return pr.String()
   137  	}
   138  	return fmt.Sprintf("AVG(%s)", sql.DebugString(a.Child))
   139  }
   140  
   141  func (a *Avg) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   142  	res := a.unaryAggBase.WithWindow(window)
   143  	return &Avg{unaryAggBase: *res.(*unaryAggBase)}
   144  }
   145  
   146  func (a *Avg) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   147  	res, err := a.unaryAggBase.WithChildren(children...)
   148  	return &Avg{unaryAggBase: *res.(*unaryAggBase)}, err
   149  }
   150  
   151  func (a *Avg) WithId(id sql.ColumnId) sql.IdExpression {
   152  	res := a.unaryAggBase.WithId(id)
   153  	return &Avg{unaryAggBase: *res.(*unaryAggBase)}
   154  }
   155  
   156  func (a *Avg) NewBuffer() (sql.AggregationBuffer, error) {
   157  	child, err := transform.Clone(a.Child)
   158  	if err != nil {
   159  		return nil, err
   160  	}
   161  	return NewAvgBuffer(child), nil
   162  }
   163  
   164  func (a *Avg) NewWindowFunction() (sql.WindowFunction, error) {
   165  	child, err := transform.Clone(a.Child)
   166  	if err != nil {
   167  		return nil, err
   168  	}
   169  	return NewAvgAgg(child).WithWindow(a.Window())
   170  }
   171  
   172  type BitAnd struct {
   173  	unaryAggBase
   174  }
   175  
   176  var _ sql.FunctionExpression = (*BitAnd)(nil)
   177  var _ sql.Aggregation = (*BitAnd)(nil)
   178  var _ sql.WindowAdaptableExpression = (*BitAnd)(nil)
   179  
   180  func NewBitAnd(e sql.Expression) *BitAnd {
   181  	return &BitAnd{
   182  		unaryAggBase{
   183  			UnaryExpression: expression.UnaryExpression{Child: e},
   184  			functionName:    "BitAnd",
   185  			description:     "returns the bitwise AND of all bits in expr.",
   186  		},
   187  	}
   188  }
   189  
   190  func (a *BitAnd) Type() sql.Type {
   191  	return types.Uint64
   192  }
   193  
   194  func (a *BitAnd) IsNullable() bool {
   195  	return false
   196  }
   197  
   198  func (a *BitAnd) String() string {
   199  	if a.window != nil {
   200  		pr := sql.NewTreePrinter()
   201  		_ = pr.WriteNode("BITAND")
   202  		children := []string{a.window.String(), a.Child.String()}
   203  		pr.WriteChildren(children...)
   204  		return pr.String()
   205  	}
   206  	return fmt.Sprintf("BITAND(%s)", a.Child)
   207  }
   208  
   209  func (a *BitAnd) DebugString() string {
   210  	if a.window != nil {
   211  		pr := sql.NewTreePrinter()
   212  		_ = pr.WriteNode("BITAND")
   213  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   214  		pr.WriteChildren(children...)
   215  		return pr.String()
   216  	}
   217  	return fmt.Sprintf("BITAND(%s)", sql.DebugString(a.Child))
   218  }
   219  
   220  func (a *BitAnd) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   221  	res := a.unaryAggBase.WithWindow(window)
   222  	return &BitAnd{unaryAggBase: *res.(*unaryAggBase)}
   223  }
   224  
   225  func (a *BitAnd) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   226  	res, err := a.unaryAggBase.WithChildren(children...)
   227  	return &BitAnd{unaryAggBase: *res.(*unaryAggBase)}, err
   228  }
   229  
   230  func (a *BitAnd) WithId(id sql.ColumnId) sql.IdExpression {
   231  	res := a.unaryAggBase.WithId(id)
   232  	return &BitAnd{unaryAggBase: *res.(*unaryAggBase)}
   233  }
   234  
   235  func (a *BitAnd) NewBuffer() (sql.AggregationBuffer, error) {
   236  	child, err := transform.Clone(a.Child)
   237  	if err != nil {
   238  		return nil, err
   239  	}
   240  	return NewBitAndBuffer(child), nil
   241  }
   242  
   243  func (a *BitAnd) NewWindowFunction() (sql.WindowFunction, error) {
   244  	child, err := transform.Clone(a.Child)
   245  	if err != nil {
   246  		return nil, err
   247  	}
   248  	return NewBitAndAgg(child).WithWindow(a.Window())
   249  }
   250  
   251  type BitOr struct {
   252  	unaryAggBase
   253  }
   254  
   255  var _ sql.FunctionExpression = (*BitOr)(nil)
   256  var _ sql.Aggregation = (*BitOr)(nil)
   257  var _ sql.WindowAdaptableExpression = (*BitOr)(nil)
   258  
   259  func NewBitOr(e sql.Expression) *BitOr {
   260  	return &BitOr{
   261  		unaryAggBase{
   262  			UnaryExpression: expression.UnaryExpression{Child: e},
   263  			functionName:    "BitOr",
   264  			description:     "returns the bitwise OR of all bits in expr.",
   265  		},
   266  	}
   267  }
   268  
   269  func (a *BitOr) Type() sql.Type {
   270  	return types.Uint64
   271  }
   272  
   273  func (a *BitOr) IsNullable() bool {
   274  	return false
   275  }
   276  
   277  func (a *BitOr) String() string {
   278  	if a.window != nil {
   279  		pr := sql.NewTreePrinter()
   280  		_ = pr.WriteNode("BITOR")
   281  		children := []string{a.window.String(), a.Child.String()}
   282  		pr.WriteChildren(children...)
   283  		return pr.String()
   284  	}
   285  	return fmt.Sprintf("BITOR(%s)", a.Child)
   286  }
   287  
   288  func (a *BitOr) DebugString() string {
   289  	if a.window != nil {
   290  		pr := sql.NewTreePrinter()
   291  		_ = pr.WriteNode("BITOR")
   292  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   293  		pr.WriteChildren(children...)
   294  		return pr.String()
   295  	}
   296  	return fmt.Sprintf("BITOR(%s)", sql.DebugString(a.Child))
   297  }
   298  
   299  func (a *BitOr) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   300  	res := a.unaryAggBase.WithWindow(window)
   301  	return &BitOr{unaryAggBase: *res.(*unaryAggBase)}
   302  }
   303  
   304  func (a *BitOr) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   305  	res, err := a.unaryAggBase.WithChildren(children...)
   306  	return &BitOr{unaryAggBase: *res.(*unaryAggBase)}, err
   307  }
   308  
   309  func (a *BitOr) WithId(id sql.ColumnId) sql.IdExpression {
   310  	res := a.unaryAggBase.WithId(id)
   311  	return &BitOr{unaryAggBase: *res.(*unaryAggBase)}
   312  }
   313  
   314  func (a *BitOr) NewBuffer() (sql.AggregationBuffer, error) {
   315  	child, err := transform.Clone(a.Child)
   316  	if err != nil {
   317  		return nil, err
   318  	}
   319  	return NewBitOrBuffer(child), nil
   320  }
   321  
   322  func (a *BitOr) NewWindowFunction() (sql.WindowFunction, error) {
   323  	child, err := transform.Clone(a.Child)
   324  	if err != nil {
   325  		return nil, err
   326  	}
   327  	return NewBitOrAgg(child).WithWindow(a.Window())
   328  }
   329  
   330  type BitXor struct {
   331  	unaryAggBase
   332  }
   333  
   334  var _ sql.FunctionExpression = (*BitXor)(nil)
   335  var _ sql.Aggregation = (*BitXor)(nil)
   336  var _ sql.WindowAdaptableExpression = (*BitXor)(nil)
   337  
   338  func NewBitXor(e sql.Expression) *BitXor {
   339  	return &BitXor{
   340  		unaryAggBase{
   341  			UnaryExpression: expression.UnaryExpression{Child: e},
   342  			functionName:    "BitXor",
   343  			description:     "returns the bitwise XOR of all bits in expr.",
   344  		},
   345  	}
   346  }
   347  
   348  func (a *BitXor) Type() sql.Type {
   349  	return types.Uint64
   350  }
   351  
   352  func (a *BitXor) IsNullable() bool {
   353  	return false
   354  }
   355  
   356  func (a *BitXor) String() string {
   357  	if a.window != nil {
   358  		pr := sql.NewTreePrinter()
   359  		_ = pr.WriteNode("BITXOR")
   360  		children := []string{a.window.String(), a.Child.String()}
   361  		pr.WriteChildren(children...)
   362  		return pr.String()
   363  	}
   364  	return fmt.Sprintf("BITXOR(%s)", a.Child)
   365  }
   366  
   367  func (a *BitXor) DebugString() string {
   368  	if a.window != nil {
   369  		pr := sql.NewTreePrinter()
   370  		_ = pr.WriteNode("BITXOR")
   371  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   372  		pr.WriteChildren(children...)
   373  		return pr.String()
   374  	}
   375  	return fmt.Sprintf("BITXOR(%s)", sql.DebugString(a.Child))
   376  }
   377  
   378  func (a *BitXor) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   379  	res := a.unaryAggBase.WithWindow(window)
   380  	return &BitXor{unaryAggBase: *res.(*unaryAggBase)}
   381  }
   382  
   383  func (a *BitXor) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   384  	res, err := a.unaryAggBase.WithChildren(children...)
   385  	return &BitXor{unaryAggBase: *res.(*unaryAggBase)}, err
   386  }
   387  
   388  func (a *BitXor) WithId(id sql.ColumnId) sql.IdExpression {
   389  	res := a.unaryAggBase.WithId(id)
   390  	return &BitXor{unaryAggBase: *res.(*unaryAggBase)}
   391  }
   392  
   393  func (a *BitXor) NewBuffer() (sql.AggregationBuffer, error) {
   394  	child, err := transform.Clone(a.Child)
   395  	if err != nil {
   396  		return nil, err
   397  	}
   398  	return NewBitXorBuffer(child), nil
   399  }
   400  
   401  func (a *BitXor) NewWindowFunction() (sql.WindowFunction, error) {
   402  	child, err := transform.Clone(a.Child)
   403  	if err != nil {
   404  		return nil, err
   405  	}
   406  	return NewBitXorAgg(child).WithWindow(a.Window())
   407  }
   408  
   409  type Count struct {
   410  	unaryAggBase
   411  }
   412  
   413  var _ sql.FunctionExpression = (*Count)(nil)
   414  var _ sql.Aggregation = (*Count)(nil)
   415  var _ sql.WindowAdaptableExpression = (*Count)(nil)
   416  
   417  func NewCount(e sql.Expression) *Count {
   418  	return &Count{
   419  		unaryAggBase{
   420  			UnaryExpression: expression.UnaryExpression{Child: e},
   421  			functionName:    "Count",
   422  			description:     "returns a count of the number of non-NULL values of expr in the rows retrieved by a SELECT statement.",
   423  		},
   424  	}
   425  }
   426  
   427  func (a *Count) Type() sql.Type {
   428  	return types.Int64
   429  }
   430  
   431  func (a *Count) IsNullable() bool {
   432  	return false
   433  }
   434  
   435  func (a *Count) String() string {
   436  	if a.window != nil {
   437  		pr := sql.NewTreePrinter()
   438  		_ = pr.WriteNode("COUNT")
   439  		children := []string{a.window.String(), a.Child.String()}
   440  		pr.WriteChildren(children...)
   441  		return pr.String()
   442  	}
   443  	return fmt.Sprintf("COUNT(%s)", a.Child)
   444  }
   445  
   446  func (a *Count) DebugString() string {
   447  	if a.window != nil {
   448  		pr := sql.NewTreePrinter()
   449  		_ = pr.WriteNode("COUNT")
   450  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   451  		pr.WriteChildren(children...)
   452  		return pr.String()
   453  	}
   454  	return fmt.Sprintf("COUNT(%s)", sql.DebugString(a.Child))
   455  }
   456  
   457  func (a *Count) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   458  	res := a.unaryAggBase.WithWindow(window)
   459  	return &Count{unaryAggBase: *res.(*unaryAggBase)}
   460  }
   461  
   462  func (a *Count) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   463  	res, err := a.unaryAggBase.WithChildren(children...)
   464  	return &Count{unaryAggBase: *res.(*unaryAggBase)}, err
   465  }
   466  
   467  func (a *Count) WithId(id sql.ColumnId) sql.IdExpression {
   468  	res := a.unaryAggBase.WithId(id)
   469  	return &Count{unaryAggBase: *res.(*unaryAggBase)}
   470  }
   471  
   472  func (a *Count) NewBuffer() (sql.AggregationBuffer, error) {
   473  	child, err := transform.Clone(a.Child)
   474  	if err != nil {
   475  		return nil, err
   476  	}
   477  	return NewCountBuffer(child), nil
   478  }
   479  
   480  func (a *Count) NewWindowFunction() (sql.WindowFunction, error) {
   481  	child, err := transform.Clone(a.Child)
   482  	if err != nil {
   483  		return nil, err
   484  	}
   485  	return NewCountAgg(child).WithWindow(a.Window())
   486  }
   487  
   488  type First struct {
   489  	unaryAggBase
   490  }
   491  
   492  var _ sql.FunctionExpression = (*First)(nil)
   493  var _ sql.Aggregation = (*First)(nil)
   494  var _ sql.WindowAdaptableExpression = (*First)(nil)
   495  
   496  func NewFirst(e sql.Expression) *First {
   497  	return &First{
   498  		unaryAggBase{
   499  			UnaryExpression: expression.UnaryExpression{Child: e},
   500  			functionName:    "First",
   501  			description:     "returns the first value in a sequence of elements of an aggregation.",
   502  		},
   503  	}
   504  }
   505  
   506  func (a *First) Type() sql.Type {
   507  	return a.Child.Type()
   508  }
   509  
   510  func (a *First) IsNullable() bool {
   511  	return false
   512  }
   513  
   514  func (a *First) String() string {
   515  	if a.window != nil {
   516  		pr := sql.NewTreePrinter()
   517  		_ = pr.WriteNode("FIRST")
   518  		children := []string{a.window.String(), a.Child.String()}
   519  		pr.WriteChildren(children...)
   520  		return pr.String()
   521  	}
   522  	return fmt.Sprintf("FIRST(%s)", a.Child)
   523  }
   524  
   525  func (a *First) DebugString() string {
   526  	if a.window != nil {
   527  		pr := sql.NewTreePrinter()
   528  		_ = pr.WriteNode("FIRST")
   529  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   530  		pr.WriteChildren(children...)
   531  		return pr.String()
   532  	}
   533  	return fmt.Sprintf("FIRST(%s)", sql.DebugString(a.Child))
   534  }
   535  
   536  func (a *First) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   537  	res := a.unaryAggBase.WithWindow(window)
   538  	return &First{unaryAggBase: *res.(*unaryAggBase)}
   539  }
   540  
   541  func (a *First) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   542  	res, err := a.unaryAggBase.WithChildren(children...)
   543  	return &First{unaryAggBase: *res.(*unaryAggBase)}, err
   544  }
   545  
   546  func (a *First) WithId(id sql.ColumnId) sql.IdExpression {
   547  	res := a.unaryAggBase.WithId(id)
   548  	return &First{unaryAggBase: *res.(*unaryAggBase)}
   549  }
   550  
   551  func (a *First) NewBuffer() (sql.AggregationBuffer, error) {
   552  	child, err := transform.Clone(a.Child)
   553  	if err != nil {
   554  		return nil, err
   555  	}
   556  	return NewFirstBuffer(child), nil
   557  }
   558  
   559  func (a *First) NewWindowFunction() (sql.WindowFunction, error) {
   560  	child, err := transform.Clone(a.Child)
   561  	if err != nil {
   562  		return nil, err
   563  	}
   564  	return NewFirstAgg(child).WithWindow(a.Window())
   565  }
   566  
   567  type JsonArray struct {
   568  	unaryAggBase
   569  }
   570  
   571  var _ sql.FunctionExpression = (*JsonArray)(nil)
   572  var _ sql.Aggregation = (*JsonArray)(nil)
   573  var _ sql.WindowAdaptableExpression = (*JsonArray)(nil)
   574  
   575  func NewJsonArray(e sql.Expression) *JsonArray {
   576  	return &JsonArray{
   577  		unaryAggBase{
   578  			UnaryExpression: expression.UnaryExpression{Child: e},
   579  			functionName:    "JsonArray",
   580  			description:     "returns result set as a single JSON array.",
   581  		},
   582  	}
   583  }
   584  
   585  func (a *JsonArray) Type() sql.Type {
   586  	return types.JSON
   587  }
   588  
   589  func (a *JsonArray) IsNullable() bool {
   590  	return false
   591  }
   592  
   593  func (a *JsonArray) String() string {
   594  	if a.window != nil {
   595  		pr := sql.NewTreePrinter()
   596  		_ = pr.WriteNode("JSON_ARRAYAGG")
   597  		children := []string{a.window.String(), a.Child.String()}
   598  		pr.WriteChildren(children...)
   599  		return pr.String()
   600  	}
   601  	return fmt.Sprintf("JSON_ARRAYAGG(%s)", a.Child)
   602  }
   603  
   604  func (a *JsonArray) DebugString() string {
   605  	if a.window != nil {
   606  		pr := sql.NewTreePrinter()
   607  		_ = pr.WriteNode("JSON_ARRAYAGG")
   608  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   609  		pr.WriteChildren(children...)
   610  		return pr.String()
   611  	}
   612  	return fmt.Sprintf("JSON_ARRAYAGG(%s)", sql.DebugString(a.Child))
   613  }
   614  
   615  func (a *JsonArray) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   616  	res := a.unaryAggBase.WithWindow(window)
   617  	return &JsonArray{unaryAggBase: *res.(*unaryAggBase)}
   618  }
   619  
   620  func (a *JsonArray) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   621  	res, err := a.unaryAggBase.WithChildren(children...)
   622  	return &JsonArray{unaryAggBase: *res.(*unaryAggBase)}, err
   623  }
   624  
   625  func (a *JsonArray) WithId(id sql.ColumnId) sql.IdExpression {
   626  	res := a.unaryAggBase.WithId(id)
   627  	return &JsonArray{unaryAggBase: *res.(*unaryAggBase)}
   628  }
   629  
   630  func (a *JsonArray) NewBuffer() (sql.AggregationBuffer, error) {
   631  	child, err := transform.Clone(a.Child)
   632  	if err != nil {
   633  		return nil, err
   634  	}
   635  	return NewJsonArrayBuffer(child), nil
   636  }
   637  
   638  func (a *JsonArray) NewWindowFunction() (sql.WindowFunction, error) {
   639  	child, err := transform.Clone(a.Child)
   640  	if err != nil {
   641  		return nil, err
   642  	}
   643  	return NewJsonArrayAgg(child).WithWindow(a.Window())
   644  }
   645  
   646  type Last struct {
   647  	unaryAggBase
   648  }
   649  
   650  var _ sql.FunctionExpression = (*Last)(nil)
   651  var _ sql.Aggregation = (*Last)(nil)
   652  var _ sql.WindowAdaptableExpression = (*Last)(nil)
   653  
   654  func NewLast(e sql.Expression) *Last {
   655  	return &Last{
   656  		unaryAggBase{
   657  			UnaryExpression: expression.UnaryExpression{Child: e},
   658  			functionName:    "Last",
   659  			description:     "returns the last value in a sequence of elements of an aggregation.",
   660  		},
   661  	}
   662  }
   663  
   664  func (a *Last) Type() sql.Type {
   665  	return a.Child.Type()
   666  }
   667  
   668  func (a *Last) IsNullable() bool {
   669  	return false
   670  }
   671  
   672  func (a *Last) String() string {
   673  	if a.window != nil {
   674  		pr := sql.NewTreePrinter()
   675  		_ = pr.WriteNode("LAST")
   676  		children := []string{a.window.String(), a.Child.String()}
   677  		pr.WriteChildren(children...)
   678  		return pr.String()
   679  	}
   680  	return fmt.Sprintf("LAST(%s)", a.Child)
   681  }
   682  
   683  func (a *Last) DebugString() string {
   684  	if a.window != nil {
   685  		pr := sql.NewTreePrinter()
   686  		_ = pr.WriteNode("LAST")
   687  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   688  		pr.WriteChildren(children...)
   689  		return pr.String()
   690  	}
   691  	return fmt.Sprintf("LAST(%s)", sql.DebugString(a.Child))
   692  }
   693  
   694  func (a *Last) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   695  	res := a.unaryAggBase.WithWindow(window)
   696  	return &Last{unaryAggBase: *res.(*unaryAggBase)}
   697  }
   698  
   699  func (a *Last) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   700  	res, err := a.unaryAggBase.WithChildren(children...)
   701  	return &Last{unaryAggBase: *res.(*unaryAggBase)}, err
   702  }
   703  
   704  func (a *Last) WithId(id sql.ColumnId) sql.IdExpression {
   705  	res := a.unaryAggBase.WithId(id)
   706  	return &Last{unaryAggBase: *res.(*unaryAggBase)}
   707  }
   708  
   709  func (a *Last) NewBuffer() (sql.AggregationBuffer, error) {
   710  	child, err := transform.Clone(a.Child)
   711  	if err != nil {
   712  		return nil, err
   713  	}
   714  	return NewLastBuffer(child), nil
   715  }
   716  
   717  func (a *Last) NewWindowFunction() (sql.WindowFunction, error) {
   718  	child, err := transform.Clone(a.Child)
   719  	if err != nil {
   720  		return nil, err
   721  	}
   722  	return NewLastAgg(child).WithWindow(a.Window())
   723  }
   724  
   725  type Max struct {
   726  	unaryAggBase
   727  }
   728  
   729  var _ sql.FunctionExpression = (*Max)(nil)
   730  var _ sql.Aggregation = (*Max)(nil)
   731  var _ sql.WindowAdaptableExpression = (*Max)(nil)
   732  
   733  func NewMax(e sql.Expression) *Max {
   734  	return &Max{
   735  		unaryAggBase{
   736  			UnaryExpression: expression.UnaryExpression{Child: e},
   737  			functionName:    "Max",
   738  			description:     "returns the maximum value of expr in all rows.",
   739  		},
   740  	}
   741  }
   742  
   743  func (a *Max) Type() sql.Type {
   744  	return a.Child.Type()
   745  }
   746  
   747  func (a *Max) IsNullable() bool {
   748  	return false
   749  }
   750  
   751  func (a *Max) String() string {
   752  	if a.window != nil {
   753  		pr := sql.NewTreePrinter()
   754  		_ = pr.WriteNode("MAX")
   755  		children := []string{a.window.String(), a.Child.String()}
   756  		pr.WriteChildren(children...)
   757  		return pr.String()
   758  	}
   759  	return fmt.Sprintf("MAX(%s)", a.Child)
   760  }
   761  
   762  func (a *Max) DebugString() string {
   763  	if a.window != nil {
   764  		pr := sql.NewTreePrinter()
   765  		_ = pr.WriteNode("MAX")
   766  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   767  		pr.WriteChildren(children...)
   768  		return pr.String()
   769  	}
   770  	return fmt.Sprintf("MAX(%s)", sql.DebugString(a.Child))
   771  }
   772  
   773  func (a *Max) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   774  	res := a.unaryAggBase.WithWindow(window)
   775  	return &Max{unaryAggBase: *res.(*unaryAggBase)}
   776  }
   777  
   778  func (a *Max) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   779  	res, err := a.unaryAggBase.WithChildren(children...)
   780  	return &Max{unaryAggBase: *res.(*unaryAggBase)}, err
   781  }
   782  
   783  func (a *Max) WithId(id sql.ColumnId) sql.IdExpression {
   784  	res := a.unaryAggBase.WithId(id)
   785  	return &Max{unaryAggBase: *res.(*unaryAggBase)}
   786  }
   787  
   788  func (a *Max) NewBuffer() (sql.AggregationBuffer, error) {
   789  	child, err := transform.Clone(a.Child)
   790  	if err != nil {
   791  		return nil, err
   792  	}
   793  	return NewMaxBuffer(child), nil
   794  }
   795  
   796  func (a *Max) NewWindowFunction() (sql.WindowFunction, error) {
   797  	child, err := transform.Clone(a.Child)
   798  	if err != nil {
   799  		return nil, err
   800  	}
   801  	return NewMaxAgg(child).WithWindow(a.Window())
   802  }
   803  
   804  type Min struct {
   805  	unaryAggBase
   806  }
   807  
   808  var _ sql.FunctionExpression = (*Min)(nil)
   809  var _ sql.Aggregation = (*Min)(nil)
   810  var _ sql.WindowAdaptableExpression = (*Min)(nil)
   811  
   812  func NewMin(e sql.Expression) *Min {
   813  	return &Min{
   814  		unaryAggBase{
   815  			UnaryExpression: expression.UnaryExpression{Child: e},
   816  			functionName:    "Min",
   817  			description:     "returns the minimum value of expr in all rows.",
   818  		},
   819  	}
   820  }
   821  
   822  func (a *Min) Type() sql.Type {
   823  	return a.Child.Type()
   824  }
   825  
   826  func (a *Min) IsNullable() bool {
   827  	return false
   828  }
   829  
   830  func (a *Min) String() string {
   831  	if a.window != nil {
   832  		pr := sql.NewTreePrinter()
   833  		_ = pr.WriteNode("MIN")
   834  		children := []string{a.window.String(), a.Child.String()}
   835  		pr.WriteChildren(children...)
   836  		return pr.String()
   837  	}
   838  	return fmt.Sprintf("MIN(%s)", a.Child)
   839  }
   840  
   841  func (a *Min) DebugString() string {
   842  	if a.window != nil {
   843  		pr := sql.NewTreePrinter()
   844  		_ = pr.WriteNode("MIN")
   845  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   846  		pr.WriteChildren(children...)
   847  		return pr.String()
   848  	}
   849  	return fmt.Sprintf("MIN(%s)", sql.DebugString(a.Child))
   850  }
   851  
   852  func (a *Min) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   853  	res := a.unaryAggBase.WithWindow(window)
   854  	return &Min{unaryAggBase: *res.(*unaryAggBase)}
   855  }
   856  
   857  func (a *Min) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   858  	res, err := a.unaryAggBase.WithChildren(children...)
   859  	return &Min{unaryAggBase: *res.(*unaryAggBase)}, err
   860  }
   861  
   862  func (a *Min) WithId(id sql.ColumnId) sql.IdExpression {
   863  	res := a.unaryAggBase.WithId(id)
   864  	return &Min{unaryAggBase: *res.(*unaryAggBase)}
   865  }
   866  
   867  func (a *Min) NewBuffer() (sql.AggregationBuffer, error) {
   868  	child, err := transform.Clone(a.Child)
   869  	if err != nil {
   870  		return nil, err
   871  	}
   872  	return NewMinBuffer(child), nil
   873  }
   874  
   875  func (a *Min) NewWindowFunction() (sql.WindowFunction, error) {
   876  	child, err := transform.Clone(a.Child)
   877  	if err != nil {
   878  		return nil, err
   879  	}
   880  	return NewMinAgg(child).WithWindow(a.Window())
   881  }
   882  
   883  type Sum struct {
   884  	unaryAggBase
   885  }
   886  
   887  var _ sql.FunctionExpression = (*Sum)(nil)
   888  var _ sql.Aggregation = (*Sum)(nil)
   889  var _ sql.WindowAdaptableExpression = (*Sum)(nil)
   890  
   891  func NewSum(e sql.Expression) *Sum {
   892  	return &Sum{
   893  		unaryAggBase{
   894  			UnaryExpression: expression.UnaryExpression{Child: e},
   895  			functionName:    "Sum",
   896  			description:     "returns the sum of expr in all rows",
   897  		},
   898  	}
   899  }
   900  
   901  func (a *Sum) Type() sql.Type {
   902  	return a.Child.Type()
   903  }
   904  
   905  func (a *Sum) IsNullable() bool {
   906  	return false
   907  }
   908  
   909  func (a *Sum) String() string {
   910  	if a.window != nil {
   911  		pr := sql.NewTreePrinter()
   912  		_ = pr.WriteNode("SUM")
   913  		children := []string{a.window.String(), a.Child.String()}
   914  		pr.WriteChildren(children...)
   915  		return pr.String()
   916  	}
   917  	return fmt.Sprintf("SUM(%s)", a.Child)
   918  }
   919  
   920  func (a *Sum) DebugString() string {
   921  	if a.window != nil {
   922  		pr := sql.NewTreePrinter()
   923  		_ = pr.WriteNode("SUM")
   924  		children := []string{sql.DebugString(a.window), sql.DebugString(a.Child)}
   925  		pr.WriteChildren(children...)
   926  		return pr.String()
   927  	}
   928  	return fmt.Sprintf("SUM(%s)", sql.DebugString(a.Child))
   929  }
   930  
   931  func (a *Sum) WithWindow(window *sql.WindowDefinition) sql.WindowAdaptableExpression {
   932  	res := a.unaryAggBase.WithWindow(window)
   933  	return &Sum{unaryAggBase: *res.(*unaryAggBase)}
   934  }
   935  
   936  func (a *Sum) WithChildren(children ...sql.Expression) (sql.Expression, error) {
   937  	res, err := a.unaryAggBase.WithChildren(children...)
   938  	return &Sum{unaryAggBase: *res.(*unaryAggBase)}, err
   939  }
   940  
   941  func (a *Sum) WithId(id sql.ColumnId) sql.IdExpression {
   942  	res := a.unaryAggBase.WithId(id)
   943  	return &Sum{unaryAggBase: *res.(*unaryAggBase)}
   944  }
   945  
   946  func (a *Sum) NewBuffer() (sql.AggregationBuffer, error) {
   947  	child, err := transform.Clone(a.Child)
   948  	if err != nil {
   949  		return nil, err
   950  	}
   951  	return NewSumBuffer(child), nil
   952  }
   953  
   954  func (a *Sum) NewWindowFunction() (sql.WindowFunction, error) {
   955  	child, err := transform.Clone(a.Child)
   956  	if err != nil {
   957  		return nil, err
   958  	}
   959  	return NewSumAgg(child).WithWindow(a.Window())
   960  }