edd*_*ark 9 json apache-spark parquet apache-spark-sql
我是Apache Spark 1.3.1的新手.如何将JSON文件转换为Parquet?
Ram*_*ami 14
Spark 1.4及更高版本
您可以使用sparkSQL首先将JSON文件读入DataFrame,然后将DataFrame写为镶木地板文件.
val df = sqlContext.read.json("path/to/json/file")
df.write.parquet("path/to/parquet/file")
Run Code Online (Sandbox Code Playgroud)
要么
df.save("path/to/parquet/file", "parquet")
Run Code Online (Sandbox Code Playgroud)
Spark 1.3.1
val df = sqlContext.jsonFile("path/to/json/file")
df.saveAsParquetFile("path/to/parquet/file")
Run Code Online (Sandbox Code Playgroud)
与Windows和Spark 1.3.1相关的问题
保存数据帧作为Windows拼花文件将抛出java.lang.NullPointerException
,如所描述这里.
在这种情况下,请考虑升级到更新的Spark版本.