2016-08-23 98 views
0

我試圖創建jsonrdd使用SQL上下文,但得到下面的錯誤。我已經把代碼和下面的錯誤..請建議..星火SQL JSON錯誤

我的代碼:

rdd1=sqlContext.jsonRDD('/idn/home/ijamalmo/ibfiles/datafiles/sampledata.json') 

錯誤

Traceback (most recent call last):

File "", line 1, in

File "/opt/mapr/spark/spark-1.4.1/python/pyspark/sql/context.py", line 442, in jsonRDD

keyed = rdd.mapPartitions(func) 

AttributeError: 'str' object has no attribute 'mapPartitions'

回答

0

jsonRDD不是pyspark功能。你想:

rdd1 = sqlContext.read.json('fileLoc').rdd 
+0

sqlCon = SQLContext(SC) RDD1集= sqlCon.jsonFile( 'smapledata.json') 該命令沒有任何錯誤執行。但是,當我試圖打印架構或打印數據它thrwoing錯誤 rdd1.printSchema() rdd1.collect() 請指教 –