来源:https://stackoverflow.com/questions/39619782/how-to-read-in-memory-json-string-into-spark-dataframe


先将字符串转为RDD,再由RDD转为DF。

From Spark SQL guide:

val otherPeopleRDD = spark.sparkContext.makeRDD(
"""{"name":"Yin","address":{"city":"Columbus","state":"Ohio"}}""" :: Nil)
val otherPeople = spark.read.json(otherPeopleRDD)
otherPeople.show()

This creates a DataFrame from an intermediate RDD (created by passing a String).

 

相关文章:

  • 2022-12-23
  • 2022-02-25
  • 2021-08-04
  • 2021-07-29
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
相关资源
相似解决方案