Class: Gitlab::Database::Aggregation::ClickHouse::Column

Inherits:
PartDefinition
  • Object
show all
Defined in:
lib/gitlab/database/aggregation/click_house/column.rb

Direct Known Subclasses

Count, DateBucketDimension, Mean, Quantile, Rate

Instance Attribute Summary collapse

Attributes inherited from PartDefinition

#description, #formatter

Instance Method Summary collapse

Methods inherited from PartDefinition

#format_value, #identifier, #instance_key, #validate_part

Constructor Details

#initialize(*args, **kwargs) ⇒ Column

Returns a new instance of Column.



10
11
12
13
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 10

def initialize(*args, **kwargs)
  super
  @secondary_expression = kwargs[:if]
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



8
9
10
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 8

def expression
  @expression
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 8

def name
  @name
end

#secondary_expressionObject (readonly)

Returns the value of attribute secondary_expression.



8
9
10
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 8

def secondary_expression
  @secondary_expression
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 8

def type
  @type
end

Instance Method Details

#secondary_arel(_context) ⇒ Object



15
16
17
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 15

def secondary_arel(_context)
  secondary_expression&.call
end

#to_inner_arel(context) ⇒ Object



19
20
21
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 19

def to_inner_arel(context)
  expression ? expression.call : context[:scope][name]
end

#to_outer_arel(context) ⇒ Object



23
24
25
# File 'lib/gitlab/database/aggregation/click_house/column.rb', line 23

def to_outer_arel(context)
  Arel::Table.new(context[:inner_query_name])[context.fetch(:local_alias, name)]
end