title: Create a hive table from a file containing data in the form Map(retweet -> 0,loc -> none)
body: <p>How do I create a hive table from a file containing data in the form                    </p>
  
  <p>Map(retweet -> 0, location -> None, sentiment -> NEUTRAL, text -> Here's another best-kept secret of Bengaluru. Check it out!Want to share the city's secret? Send them in and we w…, language -> en, created_at -> 1528369782000, user -> BangaloreTimes1, hashtags -> [Ljava.lang.String;@6acc78cc)</p>
  
  <p>Below code is generating the o/p.</p>
  
  <pre><code>      englishtweets.foreachRDD{(rdd, time) =&gt;
     rdd.map(t =&gt; {
       Map(
         "user"-&gt; t.getUser.getScreenName,
         "created_at" -&gt; t.getCreatedAt.getTime.toString,
         "location" -&gt; Option(t.getGeoLocation).map(geo =&gt; { s"${geo.getLatitude},${geo.getLongitude}" }),
         "text" -&gt; t.getText,
         "hashtags" -&gt; t.getHashtagEntities.map(_.getText),
         "retweet" -&gt; t.getRetweetCount,
         "language" -&gt; t.getLang.toString(),
         "sentiment" -&gt; detectSentiment(t.getText).toString
       )
     }).saveAsTextFile("output.txt")     
  </code></pre>
  
  <p>I could have directly stored it as Json (code below ) if I don't have to attach sentiment of each tweet.</p>
  
  <pre><code>   englishtweets.foreachRDD{(rdd, time) =&gt;
     rdd.saveAsTextFile("output")}
  </code></pre>