spark: What is the difference between Aggregator and UDAF?

北战南征 提交于 2019-12-04 15:01:05

A fundamental difference, apart from types, is external interface:

  • Aggregator takes a complete Row (it is intended for "strongly" typed API).
  • UserDefinedAggregationFunction takes a set of Columns.

This makes Aggregator less flexible, although overall API is far more user friendly.

There is also a difference with handling state:

  • Aggregator is stateful. Depends on mutable internal state of its buffer field.
  • UserDefinedAggregateFunction is stateless. State of the buffer is external.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!