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

     1  // Code generated by optgen; DO NOT EDIT.
     2  
     3  package aggregation
     4  
     5  import (
     6  	"github.com/dolthub/go-mysql-server/sql"
     7  	"github.com/dolthub/go-mysql-server/sql/expression"
     8  )
     9  
    10  type RowsUnboundedPrecedingToNPrecedingFramer struct {
    11  	rowFramerBase
    12  }
    13  
    14  var _ sql.WindowFramer = (*RowsUnboundedPrecedingToNPrecedingFramer)(nil)
    15  
    16  func NewRowsUnboundedPrecedingToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
    17  	unboundedPreceding := true
    18  	endNPreceding, err := expression.LiteralToInt(frame.EndNPreceding())
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  	return &RowsUnboundedPrecedingToNPrecedingFramer{
    23  		rowFramerBase{
    24  			unboundedPreceding: unboundedPreceding,
    25  			endNPreceding:      endNPreceding,
    26  		},
    27  	}, nil
    28  }
    29  
    30  type RowsUnboundedPrecedingToCurrentRowFramer struct {
    31  	rowFramerBase
    32  }
    33  
    34  var _ sql.WindowFramer = (*RowsUnboundedPrecedingToCurrentRowFramer)(nil)
    35  
    36  func NewRowsUnboundedPrecedingToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
    37  	unboundedPreceding := true
    38  	endCurrentRow := true
    39  	return &RowsUnboundedPrecedingToCurrentRowFramer{
    40  		rowFramerBase{
    41  			unboundedPreceding: unboundedPreceding,
    42  			endCurrentRow:      endCurrentRow,
    43  		},
    44  	}, nil
    45  }
    46  
    47  type RowsUnboundedPrecedingToNFollowingFramer struct {
    48  	rowFramerBase
    49  }
    50  
    51  var _ sql.WindowFramer = (*RowsUnboundedPrecedingToNFollowingFramer)(nil)
    52  
    53  func NewRowsUnboundedPrecedingToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
    54  	unboundedPreceding := true
    55  	endNFollowing, err := expression.LiteralToInt(frame.EndNFollowing())
    56  	if err != nil {
    57  		return nil, err
    58  	}
    59  	return &RowsUnboundedPrecedingToNFollowingFramer{
    60  		rowFramerBase{
    61  			unboundedPreceding: unboundedPreceding,
    62  			endNFollowing:      endNFollowing,
    63  		},
    64  	}, nil
    65  }
    66  
    67  type RowsUnboundedPrecedingToUnboundedFollowingFramer struct {
    68  	rowFramerBase
    69  }
    70  
    71  var _ sql.WindowFramer = (*RowsUnboundedPrecedingToUnboundedFollowingFramer)(nil)
    72  
    73  func NewRowsUnboundedPrecedingToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
    74  	unboundedPreceding := true
    75  	unboundedFollowing := true
    76  	return &RowsUnboundedPrecedingToUnboundedFollowingFramer{
    77  		rowFramerBase{
    78  			unboundedPreceding: unboundedPreceding,
    79  			unboundedFollowing: unboundedFollowing,
    80  		},
    81  	}, nil
    82  }
    83  
    84  type RowsNPrecedingToNPrecedingFramer struct {
    85  	rowFramerBase
    86  }
    87  
    88  var _ sql.WindowFramer = (*RowsNPrecedingToNPrecedingFramer)(nil)
    89  
    90  func NewRowsNPrecedingToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
    91  	startNPreceding, err := expression.LiteralToInt(frame.StartNPreceding())
    92  	if err != nil {
    93  		return nil, err
    94  	}
    95  	endNPreceding, err := expression.LiteralToInt(frame.EndNPreceding())
    96  	if err != nil {
    97  		return nil, err
    98  	}
    99  	return &RowsNPrecedingToNPrecedingFramer{
   100  		rowFramerBase{
   101  			startNPreceding: startNPreceding,
   102  			endNPreceding:   endNPreceding,
   103  		},
   104  	}, nil
   105  }
   106  
   107  type RowsNPrecedingToCurrentRowFramer struct {
   108  	rowFramerBase
   109  }
   110  
   111  var _ sql.WindowFramer = (*RowsNPrecedingToCurrentRowFramer)(nil)
   112  
   113  func NewRowsNPrecedingToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   114  	startNPreceding, err := expression.LiteralToInt(frame.StartNPreceding())
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	endCurrentRow := true
   119  	return &RowsNPrecedingToCurrentRowFramer{
   120  		rowFramerBase{
   121  			startNPreceding: startNPreceding,
   122  			endCurrentRow:   endCurrentRow,
   123  		},
   124  	}, nil
   125  }
   126  
   127  type RowsNPrecedingToNFollowingFramer struct {
   128  	rowFramerBase
   129  }
   130  
   131  var _ sql.WindowFramer = (*RowsNPrecedingToNFollowingFramer)(nil)
   132  
   133  func NewRowsNPrecedingToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   134  	startNPreceding, err := expression.LiteralToInt(frame.StartNPreceding())
   135  	if err != nil {
   136  		return nil, err
   137  	}
   138  	endNFollowing, err := expression.LiteralToInt(frame.EndNFollowing())
   139  	if err != nil {
   140  		return nil, err
   141  	}
   142  	return &RowsNPrecedingToNFollowingFramer{
   143  		rowFramerBase{
   144  			startNPreceding: startNPreceding,
   145  			endNFollowing:   endNFollowing,
   146  		},
   147  	}, nil
   148  }
   149  
   150  type RowsNPrecedingToUnboundedFollowingFramer struct {
   151  	rowFramerBase
   152  }
   153  
   154  var _ sql.WindowFramer = (*RowsNPrecedingToUnboundedFollowingFramer)(nil)
   155  
   156  func NewRowsNPrecedingToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   157  	startNPreceding, err := expression.LiteralToInt(frame.StartNPreceding())
   158  	if err != nil {
   159  		return nil, err
   160  	}
   161  	unboundedFollowing := true
   162  	return &RowsNPrecedingToUnboundedFollowingFramer{
   163  		rowFramerBase{
   164  			startNPreceding:    startNPreceding,
   165  			unboundedFollowing: unboundedFollowing,
   166  		},
   167  	}, nil
   168  }
   169  
   170  type RowsCurrentRowToNPrecedingFramer struct {
   171  	rowFramerBase
   172  }
   173  
   174  var _ sql.WindowFramer = (*RowsCurrentRowToNPrecedingFramer)(nil)
   175  
   176  func NewRowsCurrentRowToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   177  	startCurrentRow := true
   178  	endNPreceding, err := expression.LiteralToInt(frame.EndNPreceding())
   179  	if err != nil {
   180  		return nil, err
   181  	}
   182  	return &RowsCurrentRowToNPrecedingFramer{
   183  		rowFramerBase{
   184  			startCurrentRow: startCurrentRow,
   185  			endNPreceding:   endNPreceding,
   186  		},
   187  	}, nil
   188  }
   189  
   190  type RowsCurrentRowToCurrentRowFramer struct {
   191  	rowFramerBase
   192  }
   193  
   194  var _ sql.WindowFramer = (*RowsCurrentRowToCurrentRowFramer)(nil)
   195  
   196  func NewRowsCurrentRowToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   197  	startCurrentRow := true
   198  	endCurrentRow := true
   199  	return &RowsCurrentRowToCurrentRowFramer{
   200  		rowFramerBase{
   201  			startCurrentRow: startCurrentRow,
   202  			endCurrentRow:   endCurrentRow,
   203  		},
   204  	}, nil
   205  }
   206  
   207  type RowsCurrentRowToNFollowingFramer struct {
   208  	rowFramerBase
   209  }
   210  
   211  var _ sql.WindowFramer = (*RowsCurrentRowToNFollowingFramer)(nil)
   212  
   213  func NewRowsCurrentRowToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   214  	startCurrentRow := true
   215  	endNFollowing, err := expression.LiteralToInt(frame.EndNFollowing())
   216  	if err != nil {
   217  		return nil, err
   218  	}
   219  	return &RowsCurrentRowToNFollowingFramer{
   220  		rowFramerBase{
   221  			startCurrentRow: startCurrentRow,
   222  			endNFollowing:   endNFollowing,
   223  		},
   224  	}, nil
   225  }
   226  
   227  type RowsCurrentRowToUnboundedFollowingFramer struct {
   228  	rowFramerBase
   229  }
   230  
   231  var _ sql.WindowFramer = (*RowsCurrentRowToUnboundedFollowingFramer)(nil)
   232  
   233  func NewRowsCurrentRowToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   234  	startCurrentRow := true
   235  	unboundedFollowing := true
   236  	return &RowsCurrentRowToUnboundedFollowingFramer{
   237  		rowFramerBase{
   238  			startCurrentRow:    startCurrentRow,
   239  			unboundedFollowing: unboundedFollowing,
   240  		},
   241  	}, nil
   242  }
   243  
   244  type RowsNFollowingToNPrecedingFramer struct {
   245  	rowFramerBase
   246  }
   247  
   248  var _ sql.WindowFramer = (*RowsNFollowingToNPrecedingFramer)(nil)
   249  
   250  func NewRowsNFollowingToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   251  	startNFollowing, err := expression.LiteralToInt(frame.StartNFollowing())
   252  	if err != nil {
   253  		return nil, err
   254  	}
   255  	endNPreceding, err := expression.LiteralToInt(frame.EndNPreceding())
   256  	if err != nil {
   257  		return nil, err
   258  	}
   259  	return &RowsNFollowingToNPrecedingFramer{
   260  		rowFramerBase{
   261  			startNFollowing: startNFollowing,
   262  			endNPreceding:   endNPreceding,
   263  		},
   264  	}, nil
   265  }
   266  
   267  type RowsNFollowingToCurrentRowFramer struct {
   268  	rowFramerBase
   269  }
   270  
   271  var _ sql.WindowFramer = (*RowsNFollowingToCurrentRowFramer)(nil)
   272  
   273  func NewRowsNFollowingToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   274  	startNFollowing, err := expression.LiteralToInt(frame.StartNFollowing())
   275  	if err != nil {
   276  		return nil, err
   277  	}
   278  	endCurrentRow := true
   279  	return &RowsNFollowingToCurrentRowFramer{
   280  		rowFramerBase{
   281  			startNFollowing: startNFollowing,
   282  			endCurrentRow:   endCurrentRow,
   283  		},
   284  	}, nil
   285  }
   286  
   287  type RowsNFollowingToNFollowingFramer struct {
   288  	rowFramerBase
   289  }
   290  
   291  var _ sql.WindowFramer = (*RowsNFollowingToNFollowingFramer)(nil)
   292  
   293  func NewRowsNFollowingToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   294  	startNFollowing, err := expression.LiteralToInt(frame.StartNFollowing())
   295  	if err != nil {
   296  		return nil, err
   297  	}
   298  	endNFollowing, err := expression.LiteralToInt(frame.EndNFollowing())
   299  	if err != nil {
   300  		return nil, err
   301  	}
   302  	return &RowsNFollowingToNFollowingFramer{
   303  		rowFramerBase{
   304  			startNFollowing: startNFollowing,
   305  			endNFollowing:   endNFollowing,
   306  		},
   307  	}, nil
   308  }
   309  
   310  type RowsNFollowingToUnboundedFollowingFramer struct {
   311  	rowFramerBase
   312  }
   313  
   314  var _ sql.WindowFramer = (*RowsNFollowingToUnboundedFollowingFramer)(nil)
   315  
   316  func NewRowsNFollowingToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   317  	startNFollowing, err := expression.LiteralToInt(frame.StartNFollowing())
   318  	if err != nil {
   319  		return nil, err
   320  	}
   321  	unboundedFollowing := true
   322  	return &RowsNFollowingToUnboundedFollowingFramer{
   323  		rowFramerBase{
   324  			startNFollowing:    startNFollowing,
   325  			unboundedFollowing: unboundedFollowing,
   326  		},
   327  	}, nil
   328  }
   329  
   330  type RangeUnboundedPrecedingToNPrecedingFramer struct {
   331  	rangeFramerBase
   332  }
   333  
   334  var _ sql.WindowFramer = (*RangeUnboundedPrecedingToNPrecedingFramer)(nil)
   335  
   336  func NewRangeUnboundedPrecedingToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   337  	unboundedPreceding := true
   338  	endNPreceding := frame.EndNPreceding()
   339  	if len(window.OrderBy) != 1 {
   340  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   341  	}
   342  	var orderBy sql.Expression
   343  	if len(window.OrderBy) > 0 {
   344  		orderBy = window.OrderBy.ToExpressions()[0]
   345  	}
   346  	return &RangeUnboundedPrecedingToNPrecedingFramer{
   347  		rangeFramerBase{
   348  			orderBy:            orderBy,
   349  			unboundedPreceding: unboundedPreceding,
   350  			endNPreceding:      endNPreceding,
   351  		},
   352  	}, nil
   353  }
   354  
   355  type RangeUnboundedPrecedingToCurrentRowFramer struct {
   356  	rangeFramerBase
   357  }
   358  
   359  var _ sql.WindowFramer = (*RangeUnboundedPrecedingToCurrentRowFramer)(nil)
   360  
   361  func NewRangeUnboundedPrecedingToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   362  	unboundedPreceding := true
   363  	endCurrentRow := true
   364  	var orderBy sql.Expression
   365  	if len(window.OrderBy) > 0 {
   366  		orderBy = window.OrderBy.ToExpressions()[0]
   367  	}
   368  	return &RangeUnboundedPrecedingToCurrentRowFramer{
   369  		rangeFramerBase{
   370  			orderBy:            orderBy,
   371  			unboundedPreceding: unboundedPreceding,
   372  			endCurrentRow:      endCurrentRow,
   373  		},
   374  	}, nil
   375  }
   376  
   377  type RangeUnboundedPrecedingToNFollowingFramer struct {
   378  	rangeFramerBase
   379  }
   380  
   381  var _ sql.WindowFramer = (*RangeUnboundedPrecedingToNFollowingFramer)(nil)
   382  
   383  func NewRangeUnboundedPrecedingToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   384  	unboundedPreceding := true
   385  	endNFollowing := frame.EndNFollowing()
   386  	if len(window.OrderBy) != 1 {
   387  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   388  	}
   389  	var orderBy sql.Expression
   390  	if len(window.OrderBy) > 0 {
   391  		orderBy = window.OrderBy.ToExpressions()[0]
   392  	}
   393  	return &RangeUnboundedPrecedingToNFollowingFramer{
   394  		rangeFramerBase{
   395  			orderBy:            orderBy,
   396  			unboundedPreceding: unboundedPreceding,
   397  			endNFollowing:      endNFollowing,
   398  		},
   399  	}, nil
   400  }
   401  
   402  type RangeUnboundedPrecedingToUnboundedFollowingFramer struct {
   403  	rangeFramerBase
   404  }
   405  
   406  var _ sql.WindowFramer = (*RangeUnboundedPrecedingToUnboundedFollowingFramer)(nil)
   407  
   408  func NewRangeUnboundedPrecedingToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   409  	unboundedPreceding := true
   410  	unboundedFollowing := true
   411  	var orderBy sql.Expression
   412  	if len(window.OrderBy) > 0 {
   413  		orderBy = window.OrderBy.ToExpressions()[0]
   414  	}
   415  	return &RangeUnboundedPrecedingToUnboundedFollowingFramer{
   416  		rangeFramerBase{
   417  			orderBy:            orderBy,
   418  			unboundedPreceding: unboundedPreceding,
   419  			unboundedFollowing: unboundedFollowing,
   420  		},
   421  	}, nil
   422  }
   423  
   424  type RangeNPrecedingToNPrecedingFramer struct {
   425  	rangeFramerBase
   426  }
   427  
   428  var _ sql.WindowFramer = (*RangeNPrecedingToNPrecedingFramer)(nil)
   429  
   430  func NewRangeNPrecedingToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   431  	startNPreceding := frame.StartNPreceding()
   432  	endNPreceding := frame.EndNPreceding()
   433  	if len(window.OrderBy) != 1 {
   434  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   435  	}
   436  	var orderBy sql.Expression
   437  	if len(window.OrderBy) > 0 {
   438  		orderBy = window.OrderBy.ToExpressions()[0]
   439  	}
   440  	return &RangeNPrecedingToNPrecedingFramer{
   441  		rangeFramerBase{
   442  			orderBy:         orderBy,
   443  			startNPreceding: startNPreceding,
   444  			endNPreceding:   endNPreceding,
   445  		},
   446  	}, nil
   447  }
   448  
   449  type RangeNPrecedingToCurrentRowFramer struct {
   450  	rangeFramerBase
   451  }
   452  
   453  var _ sql.WindowFramer = (*RangeNPrecedingToCurrentRowFramer)(nil)
   454  
   455  func NewRangeNPrecedingToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   456  	startNPreceding := frame.StartNPreceding()
   457  	endCurrentRow := true
   458  	if len(window.OrderBy) != 1 {
   459  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   460  	}
   461  	var orderBy sql.Expression
   462  	if len(window.OrderBy) > 0 {
   463  		orderBy = window.OrderBy.ToExpressions()[0]
   464  	}
   465  	return &RangeNPrecedingToCurrentRowFramer{
   466  		rangeFramerBase{
   467  			orderBy:         orderBy,
   468  			startNPreceding: startNPreceding,
   469  			endCurrentRow:   endCurrentRow,
   470  		},
   471  	}, nil
   472  }
   473  
   474  type RangeNPrecedingToNFollowingFramer struct {
   475  	rangeFramerBase
   476  }
   477  
   478  var _ sql.WindowFramer = (*RangeNPrecedingToNFollowingFramer)(nil)
   479  
   480  func NewRangeNPrecedingToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   481  	startNPreceding := frame.StartNPreceding()
   482  	endNFollowing := frame.EndNFollowing()
   483  	if len(window.OrderBy) != 1 {
   484  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   485  	}
   486  	var orderBy sql.Expression
   487  	if len(window.OrderBy) > 0 {
   488  		orderBy = window.OrderBy.ToExpressions()[0]
   489  	}
   490  	return &RangeNPrecedingToNFollowingFramer{
   491  		rangeFramerBase{
   492  			orderBy:         orderBy,
   493  			startNPreceding: startNPreceding,
   494  			endNFollowing:   endNFollowing,
   495  		},
   496  	}, nil
   497  }
   498  
   499  type RangeNPrecedingToUnboundedFollowingFramer struct {
   500  	rangeFramerBase
   501  }
   502  
   503  var _ sql.WindowFramer = (*RangeNPrecedingToUnboundedFollowingFramer)(nil)
   504  
   505  func NewRangeNPrecedingToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   506  	startNPreceding := frame.StartNPreceding()
   507  	unboundedFollowing := true
   508  	if len(window.OrderBy) != 1 {
   509  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   510  	}
   511  	var orderBy sql.Expression
   512  	if len(window.OrderBy) > 0 {
   513  		orderBy = window.OrderBy.ToExpressions()[0]
   514  	}
   515  	return &RangeNPrecedingToUnboundedFollowingFramer{
   516  		rangeFramerBase{
   517  			orderBy:            orderBy,
   518  			startNPreceding:    startNPreceding,
   519  			unboundedFollowing: unboundedFollowing,
   520  		},
   521  	}, nil
   522  }
   523  
   524  type RangeCurrentRowToNPrecedingFramer struct {
   525  	rangeFramerBase
   526  }
   527  
   528  var _ sql.WindowFramer = (*RangeCurrentRowToNPrecedingFramer)(nil)
   529  
   530  func NewRangeCurrentRowToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   531  	startCurrentRow := true
   532  	endNPreceding := frame.EndNPreceding()
   533  	if len(window.OrderBy) != 1 {
   534  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   535  	}
   536  	var orderBy sql.Expression
   537  	if len(window.OrderBy) > 0 {
   538  		orderBy = window.OrderBy.ToExpressions()[0]
   539  	}
   540  	return &RangeCurrentRowToNPrecedingFramer{
   541  		rangeFramerBase{
   542  			orderBy:         orderBy,
   543  			startCurrentRow: startCurrentRow,
   544  			endNPreceding:   endNPreceding,
   545  		},
   546  	}, nil
   547  }
   548  
   549  type RangeCurrentRowToCurrentRowFramer struct {
   550  	rangeFramerBase
   551  }
   552  
   553  var _ sql.WindowFramer = (*RangeCurrentRowToCurrentRowFramer)(nil)
   554  
   555  func NewRangeCurrentRowToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   556  	startCurrentRow := true
   557  	endCurrentRow := true
   558  	var orderBy sql.Expression
   559  	if len(window.OrderBy) > 0 {
   560  		orderBy = window.OrderBy.ToExpressions()[0]
   561  	}
   562  	return &RangeCurrentRowToCurrentRowFramer{
   563  		rangeFramerBase{
   564  			orderBy:         orderBy,
   565  			startCurrentRow: startCurrentRow,
   566  			endCurrentRow:   endCurrentRow,
   567  		},
   568  	}, nil
   569  }
   570  
   571  type RangeCurrentRowToNFollowingFramer struct {
   572  	rangeFramerBase
   573  }
   574  
   575  var _ sql.WindowFramer = (*RangeCurrentRowToNFollowingFramer)(nil)
   576  
   577  func NewRangeCurrentRowToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   578  	startCurrentRow := true
   579  	endNFollowing := frame.EndNFollowing()
   580  	if len(window.OrderBy) != 1 {
   581  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   582  	}
   583  	var orderBy sql.Expression
   584  	if len(window.OrderBy) > 0 {
   585  		orderBy = window.OrderBy.ToExpressions()[0]
   586  	}
   587  	return &RangeCurrentRowToNFollowingFramer{
   588  		rangeFramerBase{
   589  			orderBy:         orderBy,
   590  			startCurrentRow: startCurrentRow,
   591  			endNFollowing:   endNFollowing,
   592  		},
   593  	}, nil
   594  }
   595  
   596  type RangeCurrentRowToUnboundedFollowingFramer struct {
   597  	rangeFramerBase
   598  }
   599  
   600  var _ sql.WindowFramer = (*RangeCurrentRowToUnboundedFollowingFramer)(nil)
   601  
   602  func NewRangeCurrentRowToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   603  	startCurrentRow := true
   604  	unboundedFollowing := true
   605  	var orderBy sql.Expression
   606  	if len(window.OrderBy) > 0 {
   607  		orderBy = window.OrderBy.ToExpressions()[0]
   608  	}
   609  	return &RangeCurrentRowToUnboundedFollowingFramer{
   610  		rangeFramerBase{
   611  			orderBy:            orderBy,
   612  			startCurrentRow:    startCurrentRow,
   613  			unboundedFollowing: unboundedFollowing,
   614  		},
   615  	}, nil
   616  }
   617  
   618  type RangeNFollowingToNPrecedingFramer struct {
   619  	rangeFramerBase
   620  }
   621  
   622  var _ sql.WindowFramer = (*RangeNFollowingToNPrecedingFramer)(nil)
   623  
   624  func NewRangeNFollowingToNPrecedingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   625  	startNFollowing := frame.StartNFollowing()
   626  	endNPreceding := frame.EndNPreceding()
   627  	if len(window.OrderBy) != 1 {
   628  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   629  	}
   630  	var orderBy sql.Expression
   631  	if len(window.OrderBy) > 0 {
   632  		orderBy = window.OrderBy.ToExpressions()[0]
   633  	}
   634  	return &RangeNFollowingToNPrecedingFramer{
   635  		rangeFramerBase{
   636  			orderBy:         orderBy,
   637  			startNFollowing: startNFollowing,
   638  			endNPreceding:   endNPreceding,
   639  		},
   640  	}, nil
   641  }
   642  
   643  type RangeNFollowingToCurrentRowFramer struct {
   644  	rangeFramerBase
   645  }
   646  
   647  var _ sql.WindowFramer = (*RangeNFollowingToCurrentRowFramer)(nil)
   648  
   649  func NewRangeNFollowingToCurrentRowFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   650  	startNFollowing := frame.StartNFollowing()
   651  	endCurrentRow := true
   652  	if len(window.OrderBy) != 1 {
   653  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   654  	}
   655  	var orderBy sql.Expression
   656  	if len(window.OrderBy) > 0 {
   657  		orderBy = window.OrderBy.ToExpressions()[0]
   658  	}
   659  	return &RangeNFollowingToCurrentRowFramer{
   660  		rangeFramerBase{
   661  			orderBy:         orderBy,
   662  			startNFollowing: startNFollowing,
   663  			endCurrentRow:   endCurrentRow,
   664  		},
   665  	}, nil
   666  }
   667  
   668  type RangeNFollowingToNFollowingFramer struct {
   669  	rangeFramerBase
   670  }
   671  
   672  var _ sql.WindowFramer = (*RangeNFollowingToNFollowingFramer)(nil)
   673  
   674  func NewRangeNFollowingToNFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   675  	startNFollowing := frame.StartNFollowing()
   676  	endNFollowing := frame.EndNFollowing()
   677  	if len(window.OrderBy) != 1 {
   678  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   679  	}
   680  	var orderBy sql.Expression
   681  	if len(window.OrderBy) > 0 {
   682  		orderBy = window.OrderBy.ToExpressions()[0]
   683  	}
   684  	return &RangeNFollowingToNFollowingFramer{
   685  		rangeFramerBase{
   686  			orderBy:         orderBy,
   687  			startNFollowing: startNFollowing,
   688  			endNFollowing:   endNFollowing,
   689  		},
   690  	}, nil
   691  }
   692  
   693  type RangeNFollowingToUnboundedFollowingFramer struct {
   694  	rangeFramerBase
   695  }
   696  
   697  var _ sql.WindowFramer = (*RangeNFollowingToUnboundedFollowingFramer)(nil)
   698  
   699  func NewRangeNFollowingToUnboundedFollowingFramer(frame sql.WindowFrame, window *sql.WindowDefinition) (sql.WindowFramer, error) {
   700  	startNFollowing := frame.StartNFollowing()
   701  	unboundedFollowing := true
   702  	if len(window.OrderBy) != 1 {
   703  		return nil, ErrRangeInvalidOrderBy.New(len(window.OrderBy.ToExpressions()))
   704  	}
   705  	var orderBy sql.Expression
   706  	if len(window.OrderBy) > 0 {
   707  		orderBy = window.OrderBy.ToExpressions()[0]
   708  	}
   709  	return &RangeNFollowingToUnboundedFollowingFramer{
   710  		rangeFramerBase{
   711  			orderBy:            orderBy,
   712  			startNFollowing:    startNFollowing,
   713  			unboundedFollowing: unboundedFollowing,
   714  		},
   715  	}, nil
   716  }