Handling Complex JSON Data in Spark

I have explained some Basic JSON handling in Sparking in the below link.

Handling Basic JSON Type in Spark

This blog is detailing some type of Complex JSON Data that I took some Move data from Wikipedia and converted that to a JSON Type. 

  val inputData = sc.parallelize(
    """{ "head": { "link": [], "vars": ["film", "language", "editing", "cinematography", "distributor", "producer", "runtime", "starring", "writer", "allLyrics", "artist", "caption", "country", "director", "extra", "extraColumn", "genre", "hasPhotoCollection", "label", "length", "music", "name", "released", "studio"] },
"results": { "distinct": false, "ordered": true, "bindings": [
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. Murugan" } , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "literal", "xml:lang": "en", "value": "P. Susheela and Chorus" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }    , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "213.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. S. Viswanathan" }  , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "uri", "value": "http://dbpedia.org/resource/T._M._Soundararajan" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }   , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "245.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. Murugan" } , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/M._G._Ramachandran" }   , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "literal", "xml:lang": "en", "value": "T. M. Soundararajan, P. Susheela, A. L. Raghavan, L. R. Eswari" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }     , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "246.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. Murugan" } , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/M._G._Ramachandran" }   , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "uri", "value": "http://dbpedia.org/resource/T._M._Soundararajan" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }   , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "197.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. Murugan" } , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "literal", "xml:lang": "en", "value": "T. M. Soundararajan, P. Susheela, A. L. Raghavan, L. R. Eswari" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }     , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "79.0" }      , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. S. Viswanathan" }  , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "uri", "value": "http://dbpedia.org/resource/P._Susheela" }   , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }     , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "219.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. S. Viswanathan" }  , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "literal", "xml:lang": "en", "value": "T. M. Soundararajan, P. Susheela" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" } , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }  , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" } , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }      , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "197.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. S. Viswanathan" }  , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "literal", "xml:lang": "en", "value": "A. L. Raghavan and Chorus" } , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" } , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }  , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" } , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }      , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "245.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. S. Viswanathan" }  , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/M._G._Ramachandran" }   , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "literal", "xml:lang": "en", "value": "T. M. Soundararajan, P. Susheela, A. L. Raghavan, L. R. Eswari" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }     , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "219.0" }     , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }},
  { "film": { "type": "uri", "value": "http://dbpedia.org/resource/Anbe_Vaa" }      , "language": { "type": "uri", "value": "http://dbpedia.org/resource/Tamil_language" }       , "editing": { "type": "literal", "xml:lang": "en", "value": "R. G. Gope" } , "cinematography": { "type": "literal", "xml:lang": "en", "value": "S. Maruthi Rao" }    , "distributor": { "type": "literal", "xml:lang": "en", "value": "AVM Productions" }       , "producer": { "type": "literal", "xml:lang": "en", "value": "M. Murugan" } , "runtime": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "10440.0" }   , "starring": { "type": "uri", "value": "http://dbpedia.org/resource/B._Saroja_Devi" }       , "writer": { "type": "literal", "xml:lang": "en", "value": "Aaroor Das" } , "allLyrics": { "type": "uri", "value": "http://dbpedia.org/resource/Vaali_(poet)" }  , "artist": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "caption": { "type": "literal", "xml:lang": "en", "value": "Theatrical release poster" }      , "country": { "type": "uri", "value": "http://dbpedia.org/resource/India" } , "director": { "type": "uri", "value": "http://dbpedia.org/resource/A._C._Tirulokchandar" } , "extra": { "type": "uri", "value": "http://dbpedia.org/resource/T._M._Soundararajan" }  , "extraColumn": { "type": "literal", "xml:lang": "en", "value": "Singer" }   , "genre": { "type": "uri", "value": "http://dbpedia.org/resource/Soundtrack" }    , "hasPhotoCollection": { "type": "uri", "value": "http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa" }   , "label": { "type": "uri", "value": "http://dbpedia.org/resource/Saregama" }     , "length": { "type": "typed-literal", "datatype": "http://dbpedia.org/datatype/second", "value": "79.0" }      , "music": { "type": "uri", "value": "http://dbpedia.org/resource/M._S._Viswanathan" }    , "name": { "type": "literal", "xml:lang": "en", "value": "Anbe Vaa" }   , "released": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#date", "value": "1966-01-14" }     , "studio": { "type": "uri", "value": "http://dbpedia.org/resource/AVM_Productions" }} ] } }
    """ :: Nil)
  //
  val JSONData = sCtx.read.json(inputData)
  //JSONData.printSchema()
  JSONData.registerTempTable("movietable")
  val res = sCtx.sql("select distinct results.bindings.language.value[0],results.bindings.country.value[0]," +
    "results.bindings.editing.value[0],results.bindings.cinematography.value[0],results.bindings.distributor.value[0]," +
    "results.bindings.editing.value[0],results.bindings.producer.value[0],results.bindings.runtime.value[0],results.bindings.starring.value[0]," +
    "results.bindings.writer.value[0],results.bindings.allLyrics.value[0],results.bindings.artist.value[0],results.bindings.caption.value[0]," +
    "results.bindings.cinematography.value[0],results.bindings.country.value[0],results.bindings.director.value[0]," +
    "results.bindings.distributor.value[0],results.bindings.editing.value[0],results.bindings.extra.value[0]," +
    "results.bindings.extraColumn.value[0],results.bindings.genre.value[0],results.bindings.hasPhotoCollection.value[0]," +
    "results.bindings.label.value[0],results.bindings.language.value[0],results.bindings.length.value[0]," +
    "results.bindings.music.value[0],results.bindings.name.value[0],results.bindings.producer.value[0]," +
    "results.bindings.released.value[0],results.bindings.runtime.value[0],results.bindings.starring.value[0]," +
    "results.bindings.studio.value[0] from movietable limit 1")
  res.take(10).foreach(println)

Job Output:

16/01/07 18:18:33 INFO executor.Executor: Finished task 198.0 in stage 4.0 (TID 201). 1480 bytes result sent to driver
16/01/07 18:18:33 INFO scheduler.TaskSetManager: Finished task 198.0 in stage 4.0 (TID 201) in 12 ms on localhost (199/199)
16/01/07 18:18:33 INFO scheduler.TaskSchedulerImpl: Removed TaskSet 4.0, whose tasks have all completed, from pool 
16/01/07 18:18:33 INFO scheduler.DAGScheduler: ResultStage 4 (take at JSONLoad.scala:44) finished in 2.492 s
16/01/07 18:18:33 INFO scheduler.DAGScheduler: Job 2 finished: take at JSONLoad.scala:44, took 2.519350 s
[http://dbpedia.org/resource/Tamil_language,http://dbpedia.org/resource/India,R. G. Gope,S. Maruthi Rao,AVM Productions,R. G. Gope,M. Murugan,10440.0,http://dbpedia.org/resource/B._Saroja_Devi,Aaroor Das,http://dbpedia.org/resource/Vaali_(poet),http://dbpedia.org/resource/M._S._Viswanathan,Theatrical release poster,S. Maruthi Rao,http://dbpedia.org/resource/India,http://dbpedia.org/resource/A._C._Tirulokchandar,AVM Productions,R. G. Gope,P. Susheela and Chorus,Singer,http://dbpedia.org/resource/Soundtrack,http://wifo5-03.informatik.uni-mannheim.de/flickrwrappr/photos/Anbe_Vaa,http://dbpedia.org/resource/Saregama,http://dbpedia.org/resource/Tamil_language,213.0,http://dbpedia.org/resource/M._S._Viswanathan,Anbe Vaa,M. Murugan,1966-01-14,10440.0,http://dbpedia.org/resource/B._Saroja_Devi,http://dbpedia.org/resource/AVM_Productions]

Schema Retrieval:

root
 |-- head: struct (nullable = true)
 | |-- link: array (nullable = true)
 | | |-- element: string (containsNull = true)
 | |-- vars: array (nullable = true)
 | | |-- element: string (containsNull = true)
 |-- results: struct (nullable = true)
 | |-- bindings: array (nullable = true)
 | | |-- element: struct (containsNull = true)
 | | | |-- allLyrics: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- artist: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- caption: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- cinematography: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- country: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- director: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- distributor: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- editing: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- extra: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- extraColumn: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- film: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- genre: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- hasPhotoCollection: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- label: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- language: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- length: struct (nullable = true)
 | | | | |-- datatype: string (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- music: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- name: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- producer: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | | | |-- released: struct (nullable = true)
 | | | | |-- datatype: string (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- runtime: struct (nullable = true)
 | | | | |-- datatype: string (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- starring: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- studio: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | |-- writer: struct (nullable = true)
 | | | | |-- type: string (nullable = true)
 | | | | |-- value: string (nullable = true)
 | | | | |-- xml:lang: string (nullable = true)
 | |-- distinct: boolean (nullable = true)
 | |-- ordered: boolean (nullable = true)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s