On Friday, March 18, 2016 at 2:48 AM, Punit Naik wrote:
I have some data in which I want to perform multiple 'group-by's and they are nested. Can anyone please provide me with a one-liner or anything else for nested groups-by?
--
You received this message because you are subscribed to the Google Groups "PigPen Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pigpen-suppor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
(def data (pig/load-json "/path"))
(def grouped-by-type (pig/group-by :ga_userType data))
(def grouped-by-type-id (pig/map (fn [[type d]] (->> d (pig/group-by :ga_userId))) grouped-by-type))
AssertionError Assert failed: (map? relation) pigpen.raw/eval3191/command--3192/fn--3195 (raw.clj:42)
(def grouped-by-type-id (pig/map (fn [[type d]] (->> d (group-by :ga_userId))) grouped-by-type))
[[{"userType":"F","userId":"902785","modId":"9","total_time_spent":16}],[{"userType":"F","userId":"1179688","modId":"9","total_time_spent":207}]]
->>(
(pig/mapcat concat)
(pig/map #(into {} %)))