Guest User

Untitled

a guest
Jan 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. +---+---+----+-----+-----+
  2. | F| L| Loy|Email|State|
  3. +---+---+----+-----+-----+
  4. | f1| l1|loy1| null| s1|
  5. | f1| l1|loy1| e1| s1|
  6. | f2| l2|loy2| e2| s2|
  7. | f2| l2|loy2| e3| null|
  8. | f1| l1|null| e1| s3|
  9. | f1| l1|null| e2| s3|
  10. +---+---+----+-----+-----+
  11.  
  12. df.groupBy("F", "L", "Loy").agg(collect_set($"Email").alias("Email"), collect_set($"State").alias("State")).show
  13.  
  14. +---+---+----+--------+-----+
  15. | F| L| Loy| Email|State|
  16. +---+---+----+--------+-----+
  17. | f1| l1|null|[e1, e2]| [s3]|
  18. | f2| l2|loy2|[e2, e3]| [s2]|
  19. | f1| l1|loy1| [e1]| [s1]|
  20. +---+---+----+--------+-----+
  21.  
  22. +---+---+------+--------+---------+
  23. | F| L| Loy| Email| State|
  24. +---+---+------+--------+---------+
  25. | f1| l1|[loy1]|[e1, e2]| [s3, s1]|
  26. | f2| l2|[loy2]|[e2, e3]| [s2]|
  27. +---+---+------+--------+---------+
Add Comment
Please, Sign In to add comment