当我执行以下操作时。我在centos 7.0和spark 2.1.0中遇到了这个问题。我是 Spark 中的新生。怎么解决?
>>> from pyspark.sql import SQLContext
>>> ssc = SQLContext(sc)
>>> df = ssc.jsonFile('file:///root/work/person.json')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'SQLContext' object has no attribute 'jsonFile'
最佳答案
将 SparkSession
与较新版本的 Spark 结合使用并使用
df = Spark.read.json('json 路径)
.
关于apache-spark - 属性错误: 'SQLContext' object has no attribute 'jsonFile' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44154296/