Class: Gitlab::Database::Aggregation::ClickHouse::Quantile
- Inherits:
-
Column
- Object
- PartDefinition
- Column
- Gitlab::Database::Aggregation::ClickHouse::Quantile
- Includes:
- ParameterizedDefinition
- Defined in:
- lib/gitlab/database/aggregation/click_house/quantile.rb
Constant Summary collapse
- DEFAULT_QUANTILE =
0.5
Instance Attribute Summary
Attributes included from ParameterizedDefinition
Attributes inherited from Column
#expression, #name, #secondary_expression, #type
Attributes inherited from PartDefinition
#description, #expression, #formatter, #name, #secondary_expression, #type
Instance Method Summary collapse
- #identifier ⇒ Object
-
#initialize(name, type = :float, expression = nil, **kwargs) ⇒ Quantile
constructor
A new instance of Quantile.
- #to_outer_arel(context) ⇒ Object
Methods included from ParameterizedDefinition
Methods inherited from Column
#secondary_arel, #to_inner_arel
Methods inherited from PartDefinition
#format_value, #instance_key, #validate_part
Constructor Details
#initialize(name, type = :float, expression = nil, **kwargs) ⇒ Quantile
Returns a new instance of Quantile.
14 15 16 |
# File 'lib/gitlab/database/aggregation/click_house/quantile.rb', line 14 def initialize(name, type = :float, expression = nil, **kwargs) super end |
Instance Method Details
#identifier ⇒ Object
18 19 20 |
# File 'lib/gitlab/database/aggregation/click_house/quantile.rb', line 18 def identifier :"#{name}_quantile" end |
#to_outer_arel(context) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/gitlab/database/aggregation/click_house/quantile.rb', line 22 def to_outer_arel(context) quantile = instance_parameter(:quantile, context[name]) || DEFAULT_QUANTILE inner_column = Arel::Table.new(context[:inner_query_name])[context.fetch(:local_alias, name)] Arel.sql("quantile(?)(?)", context[:scope].quote(quantile), inner_column) end |