Add BagGroup UDF and tests