AnsweredAssumed Answered

pyspark code to load data to dataframe from maprfs

Question asked by srini14171417 on May 31, 2018
Latest reply on May 31, 2018 by maprcommunity

Hi,

I am trying to load json data from maprfs directory,when i load data from local Unix system it is working fine ,but when i try to load data from maprfs using below code it throwing error

Code:::

[*************]$ python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
Type "help", "copyright", "credits" or "license" for more information.
>>>

import json

from pyspark import SparkContext

from pyspark.sql import SQLContext

from pyspark.sql.functions import udf

from pyspark.sql.functions import *

import os

sc = SparkContext("local", "First App")

sqlContext = SQLContext(sc)

dfre= sqlContext.read.format('json').load('maprfs:///user/******/*****/').withColumn("id",col("id"))

 

Error:::

 

WARN  FileStreamSink:66 - Error while looking for metadata directory.

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/lib/python2.7/site-packages/pyspark/sql/readwriter.py", line 166, in load

    return self._df(self._jreader.load(path))

  File "/usr/lib/python2.7/site-packages/py4j/java_gateway.py", line 1160, in __call__

    answer, self.gateway_client, self.target_id, self.name)

  File "/usr/lib/python2.7/site-packages/pyspark/sql/utils.py", line 63, in deco

    return f(*a, **kw)

  File "/usr/lib/python2.7/site-packages/py4j/protocol.py", line 320, in get_return_value

    format(target_id, ".", name), value)

py4j.protocol.Py4JJavaError: An error occurred while calling o675.load.

: java.io.IOException: No FileSystem for scheme: maprfs

        at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2660)

        at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2667)

        at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:94)

        at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2703)

        at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2685)

        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)

        at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295)

Outcomes