Spark SQL: How to consume json data from a REST service as DataFrame

Kiran

I need to read some JSON data from a web service thats providing REST interfaces to query the data from my SPARK SQL code for analysis. I am able to read a JSON stored in the blob store and use it.

I was wondering what is the best way to read the data from a REST service and use it like a any other DataFrame.

BTW I am using SPARK 1.6 of Linux cluster on HD insight if that helps. Also would appreciate if someone can share any code snippets for the same as I am still very new to SPARK environment.

aggFTW

On Spark 1.6:

If you are on Python, use the requests library to get the information and then just create an RDD from it. There must be some similar library for Scala (relevant thread). Then just do:

json_str = '{"executorCores": 2, "kind": "pyspark", "driverMemory": 1000}'
rdd = sc.parallelize([json_str])
json_df = sqlContext.jsonRDD(rdd)
json_df

Code for Scala:

val anotherPeopleRDD = sc.parallelize(
  """{"name":"Yin","address":{"city":"Columbus","state":"Ohio"}}""" :: Nil)
val anotherPeople = sqlContext.read.json(anotherPeopleRDD)

This is from: http://spark.apache.org/docs/latest/sql-programming-guide.html#json-datasets

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Grails 2.4.3: Consume a REST Service

From Dev

Angular resource service does not consume rest ful service in rails (Json format)

From Dev

Consume WCF Rest Service Json data across all platform using Shared Code

From Dev

Consume REST Service in XPage

From Dev

How to handle huge data from a REST service

From Dev

How to consume a JSON web service in Java

From Dev

Mule: how to consume a service from a remote client

From Dev

How to consume json parameter in java restful service

From Dev

Jasper Reports: getting JSON data from a post rest service

From Dev

How to export data from Spark SQL to CSV

From Dev

How to consume Rest Web service in c#

From Dev

Consume REST service in MVC 6

From Dev

Spark SQL: How to consume json data from a REST service as DataFrame

From Dev

Consume Json file from Service in Angular 2

From Dev

How to load data in chunks from a pandas dataframe to a spark dataframe

From Dev

consume json data in angularjs from node.js as backend and sql db

From Dev

Can Akka grpc consume data from non-Akka service

From Dev

How to create dataframe from list in Spark SQL?

From Dev

Angular resource service does not consume rest ful service in rails (Json format)

From Dev

How to consume WCF Data Service from Controller (MVC5, EF6, WCF 5.6)

From Dev

Mule: how to consume a service from a remote client

From Dev

How consume REST service with complex type in C#?

From Dev

consume rest web service in TextBlocks

From Dev

How to consume a rest web service in phonegap for android?

From Dev

how to consume data from rest api using ajax jquery

From Dev

How to consume non rest wcf service using Jquery?

From Dev

Spring consume rest json web-service error

From Dev

how to consume the json web service in objective c?

From Dev

jqgrid retrieves JSON data from rest service but does not display it

Related Related

  1. 1

    Grails 2.4.3: Consume a REST Service

  2. 2

    Angular resource service does not consume rest ful service in rails (Json format)

  3. 3

    Consume WCF Rest Service Json data across all platform using Shared Code

  4. 4

    Consume REST Service in XPage

  5. 5

    How to handle huge data from a REST service

  6. 6

    How to consume a JSON web service in Java

  7. 7

    Mule: how to consume a service from a remote client

  8. 8

    How to consume json parameter in java restful service

  9. 9

    Jasper Reports: getting JSON data from a post rest service

  10. 10

    How to export data from Spark SQL to CSV

  11. 11

    How to consume Rest Web service in c#

  12. 12

    Consume REST service in MVC 6

  13. 13

    Spark SQL: How to consume json data from a REST service as DataFrame

  14. 14

    Consume Json file from Service in Angular 2

  15. 15

    How to load data in chunks from a pandas dataframe to a spark dataframe

  16. 16

    consume json data in angularjs from node.js as backend and sql db

  17. 17

    Can Akka grpc consume data from non-Akka service

  18. 18

    How to create dataframe from list in Spark SQL?

  19. 19

    Angular resource service does not consume rest ful service in rails (Json format)

  20. 20

    How to consume WCF Data Service from Controller (MVC5, EF6, WCF 5.6)

  21. 21

    Mule: how to consume a service from a remote client

  22. 22

    How consume REST service with complex type in C#?

  23. 23

    consume rest web service in TextBlocks

  24. 24

    How to consume a rest web service in phonegap for android?

  25. 25

    how to consume data from rest api using ajax jquery

  26. 26

    How to consume non rest wcf service using Jquery?

  27. 27

    Spring consume rest json web-service error

  28. 28

    how to consume the json web service in objective c?

  29. 29

    jqgrid retrieves JSON data from rest service but does not display it

HotTag

Archive