Function - (Aggregate|Aggregation|Summary)

1 - About

Aggregate functions return a single value, calculated from values in a array.

3 - List

Example of aggregate functions:

  • AVG() - Returns the average value
  • COUNT() - Returns the number of rows
  • FIRST() - Returns the first value
  • LAST() - Returns the last value
  • MAX() - Returns the largest value
  • MIN() - Returns the smallest value
  • SUM() - Returns the sum

4 - Implementation

4.1 - Mutative operation

Mutative accumulation for a sum

int sum = 0;
for (int x : numbers) {
   sum += x;
}

4.2 - Reduction operation

They are implemented as reduction operation

4.3 - Partition

Some operations like AVG are not partitionable. It is not valid to compute them on partitioned data because they are not commutative and associative).

You can still compute partial aggregates by transforming the non-commutative and associative function by commutative and associative function and, then roll them up. For example if you want to compute AVG(x) you can expand to SUM(x) / COUNT(x), and compute partition SUM(x) and COUNT(X) on each partition then sum them using SUM.

code/function/aggregate.txt · Last modified: 2018/10/10 09:51 by gerardnico