Class: Rooq::WindowFunction
Overview
Window function expression
Constant Summary
collapse
- FrameBound =
T.type_alias { T.any(Symbol, T::Array[T.any(Symbol, Integer)]) }
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#initialize(function, partition_fields: [], order_specs: [], frame: nil) ⇒ void
constructor
-
#order_by(*specs) ⇒ Array<OrderSpecification>, WindowFunction
-
#over(partition_by: [], order_by: [], frame: nil) ⇒ WindowFunction
-
#partition_by(*fields) ⇒ Array<Expression>, WindowFunction
-
#range_between(start_bound, end_bound) ⇒ WindowFunction
-
#rows(start_bound, end_bound = nil) ⇒ WindowFunction
-
#rows_between(start_bound, end_bound) ⇒ WindowFunction
Methods inherited from Expression
#%, #*, #+, #-, #/, #as, #asc, #between, #desc, #eq, #gt, #gte, #in, #is_not_null, #is_null, #like, #lt, #lte, #ne, #to_sql
Constructor Details
#initialize(function, partition_fields: [], order_specs: [], frame: nil) ⇒ void
253
254
255
256
257
258
|
# File 'lib/rooq/expression.rb', line 253
def initialize(function, partition_fields: [], order_specs: [], frame: nil)
@function = function
@partition_fields = T.let(Array(partition_fields).freeze, T::Array[Expression])
@order_specs = T.let(Array(order_specs).freeze, T::Array[OrderSpecification])
@frame = frame
end
|
Instance Attribute Details
243
244
245
|
# File 'lib/rooq/expression.rb', line 243
def frame
@frame
end
|
240
241
242
|
# File 'lib/rooq/expression.rb', line 240
def function
@function
end
|
Instance Method Details
267
268
269
270
|
# File 'lib/rooq/expression.rb', line 267
def order_by(*specs)
return @order_specs if specs.empty?
WindowFunction.new(@function, partition_fields: @partition_fields, order_specs: @order_specs + specs.flatten, frame: @frame)
end
|
#over(partition_by: [], order_by: [], frame: nil) ⇒ WindowFunction
297
298
299
|
# File 'lib/rooq/expression.rb', line 297
def over(partition_by: [], order_by: [], frame: nil)
WindowFunction.new(@function, partition_fields: partition_by, order_specs: order_by, frame: frame)
end
|
261
262
263
264
|
# File 'lib/rooq/expression.rb', line 261
def partition_by(*fields)
return @partition_fields if fields.empty?
WindowFunction.new(@function, partition_fields: @partition_fields + fields.flatten, order_specs: @order_specs, frame: @frame)
end
|
#range_between(start_bound, end_bound) ⇒ WindowFunction
285
286
287
288
|
# File 'lib/rooq/expression.rb', line 285
def range_between(start_bound, end_bound)
new_frame = WindowFrame.new(WindowFrame::RANGE, start_bound, end_bound)
WindowFunction.new(@function, partition_fields: @partition_fields, order_specs: @order_specs, frame: new_frame)
end
|
#rows(start_bound, end_bound = nil) ⇒ WindowFunction
273
274
275
276
|
# File 'lib/rooq/expression.rb', line 273
def rows(start_bound, end_bound = nil)
new_frame = WindowFrame.new(WindowFrame::ROWS, start_bound, end_bound)
WindowFunction.new(@function, partition_fields: @partition_fields, order_specs: @order_specs, frame: new_frame)
end
|
#rows_between(start_bound, end_bound) ⇒ WindowFunction
279
280
281
282
|
# File 'lib/rooq/expression.rb', line 279
def rows_between(start_bound, end_bound)
new_frame = WindowFrame.new(WindowFrame::ROWS, start_bound, end_bound)
WindowFunction.new(@function, partition_fields: @partition_fields, order_specs: @order_specs, frame: new_frame)
end
|