Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +---+---+----+-----+-----+
- | F| L| Loy|Email|State|
- +---+---+----+-----+-----+
- | f1| l1|loy1| null| s1|
- | f1| l1|loy1| e1| s1|
- | f2| l2|loy2| e2| s2|
- | f2| l2|loy2| e3| null|
- | f1| l1|null| e1| s3|
- | f1| l1|null| e2| s3|
- +---+---+----+-----+-----+
- df.groupBy("F", "L", "Loy").agg(collect_set($"Email").alias("Email"), collect_set($"State").alias("State")).show
- +---+---+----+--------+-----+
- | F| L| Loy| Email|State|
- +---+---+----+--------+-----+
- | f1| l1|null|[e1, e2]| [s3]|
- | f2| l2|loy2|[e2, e3]| [s2]|
- | f1| l1|loy1| [e1]| [s1]|
- +---+---+----+--------+-----+
- +---+---+------+--------+---------+
- | F| L| Loy| Email| State|
- +---+---+------+--------+---------+
- | f1| l1|[loy1]|[e1, e2]| [s3, s1]|
- | f2| l2|[loy2]|[e2, e3]| [s2]|
- +---+---+------+--------+---------+
Add Comment
Please, Sign In to add comment