Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. df.show()
  2. +--------------------+--------------------+----+--------+---------+--------------------+--------+--------------------+
  3. | address| coordinates| id|latitude|longitude| name|position| json|
  4. +--------------------+--------------------+----+--------+---------+--------------------+--------+--------------------+
  5. |Balfour St / Brun...|[-27.463431, 153....|79.0| null| null|79 - BALFOUR ST /...| null|[-27.463431, 153....|
  6. +--------------------+--------------------+----+--------+---------+--------------------+--------+--------------------+
  7.  
  8. val jsonSchema = StructType(Seq(
  9. StructField("latitude", DoubleType, nullable = true),
  10. StructField("longitude", DoubleType, nullable = true)))
  11.  
  12. val a = df.select(from_json(col("json"), jsonSchema) as "content")
  13.  
  14. a.show() gives me :
  15. +-------+
  16. |content|
  17. +-------+
  18. | null|
  19. +-------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement