public Decimal128 updateVarianceDestructive(
          Decimal128 scratch, Decimal128 value, Decimal128 sum, long count) {
      scratch.update(count);
      scratch.multiplyDestructive(value, value.getScale());
      scratch.subtractDestructive(sum, sum.getScale());
      scratch.squareDestructive();
      scratch.unscaledValue.divideDestructive(count * (count-1));
      this.addDestructive(scratch, getScale());
      return this;
  }
For UDAF variance we use the algorithm described by Chan, Golub, and LeVeque in
"Algorithms for computing the sample variance: analysis and recommendations"
The American Statistician, 37 (1983) pp. 242--247.

variance = variance1 + variance2 + n/(m*(m+n)) * pow(((m/n)*t1 - t2),2)

where: - variance is sum[x-avg^2] (this is actually n times the variance)
and is updated at every step. - n is the count of elements in chunk1 - m is
the count of elements in chunk2 - t1 = sum of elements in chunk1, t2 =
sum of elements in chunk2.

This is a helper function doing the intermediate computation:
  t = myagg.count*value - myagg.sum;
  myagg.variance += (t*t) / ((double)myagg.count*(myagg.count-1));

@return self
common/src/java/org/apache/hadoop/hive/common/type/Decimal128.java