从Spark读取多个json文件 [英] Reading multiple json files from Spark
本文介绍了从Spark读取多个json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要并行加载的json文件列表.
I have a list of json files which I would like load in parallel.
我不能使用read.json("*")
,因为文件不在同一文件夹中,并且没有可以实现的特定模式.
I can't use read.json("*")
cause files are not in the same folder and there is no specific pattern I can implement.
我已经尝试过sc.parallelize(fileList).select(hiveContext.read.json)
,但是按预期,蜂巢上下文在执行程序中不存在.
I've tried sc.parallelize(fileList).select(hiveContext.read.json)
but hive context, as expected, doesn't exists in executor.
有什么想法吗?
推荐答案
好像我找到了解决方案:
Looks like I found the solution:
val text sc.textFile("file1,file2....")
val df = sqlContext.read.json(text)
这篇关于从Spark读取多个json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文