-1

I have the below json file

{
   "data": [
      {
         "id": "254094394708288_946242468826807",
         "from": {
            "name": "Emirates NBD  \u0628\u0646\u0643 \u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062a \u062f\u0628\u064a \u0627\u0644\u0648\u0637\u0646\u064a",
            "category": "Bank/Financial Institution",
            "id": "254094394708288"
         }    
      },
      {
         "id": "254094394708288_945515772232810",
         "from": {
            "name": "Emirates NBD  \u0628\u0646\u0643 \u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062a \u062f\u0628\u064a \u0627\u0644\u0648\u0637\u0646\u064a",
            "category": "Bank/Financial Institution",
            "id": "254094394708288"
         }        
      }
]
}

I want to create a hive table based on JSON objects inside "data" JSON array. I want to do this in Java. I dont want to do "select data.id,data.from from temptable". I want to do something similar to to a select * query. It should automatically infer schema from json objects. I came to find explode function in python and scala.

http://stackoverflow.com/questions/31859271/sparksql-and-explode-on-dataframe-in-java

Is there something similar in Java??

sujit
  • 455
  • 6
  • 12

1 Answers1

1

In Java there is exactly the same thing:

org.apache.spark.sql.functions.explode(Column e)

which returns Column

You could check my answer here for the details

Community
  • 1
  • 1
Yuan JI
  • 2,927
  • 2
  • 20
  • 29