build definitions and groupBy version of spark/scala