title: spark: What is the difference between Aggregator and UDAF？
body: <p>In Spark's documentation, Aggregator:</p>
  <blockquote>
  <p>abstract class Aggregator[-IN, BUF, OUT] extends Serializable</p>
  <p>A base class for user-defined aggregations, which can be
  used in Dataset operations to take all of the elements of a group and
  reduce them to a single value.</p>
  </blockquote>
  <p>UserDefinedAggregateFunction is:</p>
  <blockquote>
  <p>abstract class UserDefinedAggregateFunction extends Serializable</p>
  <p>The base class for implementing user-defined aggregate functions
  (UDAF).</p>
  </blockquote>
  <p>According to <a href="http://docs.cloud.databricks.com/docs/spark/1.6/examples/Dataset%20Aggregator.html" rel="nofollow noreferrer">Dataset Aggregator - Databricks</a>, “an Aggregator is similar to a UDAF, but the interface is expressed in terms of JVM objects instead of as a Row .”</p>
  <p>It seems these two classes are very similar, what are other differences apart from the types in the interface?</p>
  <p>A similar question is: <a href="https://stackoverflow.com/questions/45356452/performance-of-udaf-versus-aggregator-in-spark">Performance of UDAF versus Aggregator in Spark</a></p>