Module: Veritas::SQL::Generator::Function::Aggregate

Includes:
Veritas::SQL::Generator::Function
Included in:
Relation::Unary
Defined in:
lib/veritas/sql/generator/function/aggregate.rb

Overview

Generates an SQL statement for an aggregate function

Constant Summary collapse

COUNT =
'COUNT'.freeze
SUM =
'SUM'.freeze
MINIMUM =
'MIN'.freeze
MAXIMUM =
'MAX'.freeze
MEAN =
'AVG'.freeze
VARIANCE =
'VAR_POP'.freeze
STANDARD_DEVIATION =
'STDDEV_POP'.freeze

Constants included from Identifier

Identifier::ESCAPED_QUOTE, Identifier::QUOTE

Constants included from Literal

Literal::ESCAPED_QUOTE, Literal::FALSE, Literal::NULL, Literal::QUOTE, Literal::SEPARATOR, Literal::TIME_SCALE, Literal::TRUE

Instance Method Summary collapse

Methods included from Attribute

#visit_veritas_attribute

Methods included from Identifier

#visit_identifier

Methods included from Literal

dup_frozen, #visit_class, #visit_date, #visit_date_time, #visit_enumerable, #visit_false_class, #visit_nil_class, #visit_numeric, #visit_string, #visit_time, #visit_true_class

Instance Method Details

#visit_veritas_aggregate_count(count) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a count aggregate function

Parameters:

  • count (Veritas::Aggregate::Count)

Returns:

  • (#to_s)


27
28
29
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 27

def visit_veritas_aggregate_count(count)
  unary_prefix_operation_sql(COUNT, count)
end

#visit_veritas_aggregate_maximum(maximum) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a maximum aggregate function

Parameters:

  • maximum (Veritas::Aggregate::Maximum)

Returns:

  • (#to_s)


61
62
63
64
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 61

def visit_veritas_aggregate_maximum(maximum)
  # TODO: wrap this in a coalesce operation once the default can be made sane
  unary_prefix_operation_sql(MAXIMUM, maximum)
end

#visit_veritas_aggregate_mean(mean) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a mean aggregate function

Parameters:

  • mean (Veritas::Aggregate::Mean)

Returns:

  • (#to_s)


73
74
75
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 73

def visit_veritas_aggregate_mean(mean)
  unary_prefix_operation_sql(MEAN, mean)
end

#visit_veritas_aggregate_minimum(minimum) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a minimum aggregate function

Parameters:

  • minimum (Veritas::Aggregate::Minimum)

Returns:

  • (#to_s)


49
50
51
52
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 49

def visit_veritas_aggregate_minimum(minimum)
  # TODO: wrap this in a coalesce operation once the default can be made sane
  unary_prefix_operation_sql(MINIMUM, minimum)
end

#visit_veritas_aggregate_standard_deviation(standard_deviation) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a standard deviation aggregate function

Parameters:

  • standard_deviation (Veritas::Aggregate::StandardDeviation)

Returns:

  • (#to_s)


95
96
97
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 95

def visit_veritas_aggregate_standard_deviation(standard_deviation)
  unary_prefix_operation_sql(STANDARD_DEVIATION, standard_deviation)
end

#visit_veritas_aggregate_sum(sum) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a sum aggregate function

Parameters:

  • sum (Veritas::Aggregate::Sum)

Returns:

  • (#to_s)


38
39
40
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 38

def visit_veritas_aggregate_sum(sum)
  aggregate_function_sql(SUM, sum)
end

#visit_veritas_aggregate_variance(variance) ⇒ #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Visit a variance aggregate function

Parameters:

  • variance (Veritas::Aggregate::Variance)

Returns:

  • (#to_s)


84
85
86
# File 'lib/veritas/sql/generator/function/aggregate.rb', line 84

def visit_veritas_aggregate_variance(variance)
  unary_prefix_operation_sql(VARIANCE, variance)
end