Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sqlContext.sql(s"""
- SELECT
- school_name,
- name,
- age
- FROM my_table
- """)
- val df = sqlContext.sql(s"""
- SELECT
- school_name,
- age
- FROM my_table
- GROUP BY school_name
- """)
- df.groupBy("school_name").agg(make_map)
- -------------------
- school_name | map
- ------------------
- school A | {"michael": 7, "emily": 5}
- school B | {"cathy": 10, "shaun": 5}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement