Currently KTable aggregation takes a selector used for selecting the aggregate key.and an aggregator for aggregating the values with the same selected key, which makes the function a little bit "heavy":
It is better to extract the selector in a separate groupBy function such that
Note that "KTableGrouped" only have APIs for aggregate and reduce, and none else. So users have to follow the pattern below:
This pattern is more natural for users who are familiar with SQL / Pig or Spark DSL, etc.