<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to insert data into Hive from SparkSQL in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82737#M21362</link>
    <description>I am glad, so please accept it as a solution</description>
    <pubDate>Wed, 21 Nov 2018 17:51:00 GMT</pubDate>
    <dc:creator>Tomas79</dc:creator>
    <dc:date>2018-11-21T17:51:00Z</dc:date>
    <item>
      <title>How to insert data into Hive from SparkSQL</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82452#M21358</link>
      <description>&lt;P&gt;Below is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import sqlContext.implicits._&lt;/P&gt;&lt;P&gt;import org.apache.spark.sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;val eBayText = sc.textFile("/user/cloudera/spark/servicesDemo.csv")&lt;/P&gt;&lt;P&gt;val hospitalDataText = sc.textFile("/user/cloudera/spark/servicesDemo.csv")&lt;/P&gt;&lt;P&gt;val header = hospitalDataText.first()&lt;/P&gt;&lt;P&gt;val hospitalData = hospitalDataText.filter(a=&amp;gt;a!=header)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;case class Services(uhid:String,locationid:String,doctorid:String)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;val hData = hospitalData.map(_.split(",")).map(p=&amp;gt;Services(p(0),p(1),p(2)))&lt;/P&gt;&lt;P&gt;val hosService = hData.toDF()&lt;/P&gt;&lt;P&gt;hosService.write.format("parquet").mode(org.apache.spark.sql.SaveMode.Append).save("/user/hive/warehouse/hosdata")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code created 'hosdata' folder at specified path, which contains data in 'parquet' format.&lt;/P&gt;&lt;P&gt;But when i went to hive and check table got created or not the, i did not able to see any table name as 'hosdata'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i run below commands.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hosService.write.mode("overwrite").saveAsTable("hosData")&lt;/P&gt;&lt;P&gt;sqlContext.sql("show tables").show&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;shows me below result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;+--------------------+-----------+&lt;/P&gt;&lt;P&gt;| tableName|isTemporary|&lt;/P&gt;&lt;P&gt;+--------------------+-----------+&lt;/P&gt;&lt;P&gt;| hosdata| false|&lt;/P&gt;&lt;P&gt;+--------------------+-----------+&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But again when i check in hive, i can not see table 'hosdata'&lt;/P&gt;&lt;P&gt;Could anyone let me know what step i am missing?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 13:54:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82452#M21358</guid>
      <dc:creator>KedarDivekar</dc:creator>
      <dc:date>2022-09-16T13:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert data into Hive from SparkSQL</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82644#M21359</link>
      <description>Hi, that's because your spark program is not using the common hive metastore, so the definition of the table is gone when your application finishes.&lt;BR /&gt;You should create an external table in HIVE and then issue a refresh command, so after your spark application finishes, you will see new data in your table.&lt;BR /&gt;For creating external table see the Cloudera docs.</description>
      <pubDate>Tue, 20 Nov 2018 17:41:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82644#M21359</guid>
      <dc:creator>Tomas79</dc:creator>
      <dc:date>2018-11-20T17:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert data into Hive from SparkSQL</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82679#M21360</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May i know what is referesh command ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And can i see table in hive only after i close spark application?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 04:38:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82679#M21360</guid>
      <dc:creator>KedarDivekar</dc:creator>
      <dc:date>2018-11-21T04:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert data into Hive from SparkSQL</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82736#M21361</link>
      <description>&lt;P&gt;Thank You. This works for me. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 17:48:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82736#M21361</guid>
      <dc:creator>KedarDivekar</dc:creator>
      <dc:date>2018-11-21T17:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert data into Hive from SparkSQL</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82737#M21362</link>
      <description>I am glad, so please accept it as a solution</description>
      <pubDate>Wed, 21 Nov 2018 17:51:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/82737#M21362</guid>
      <dc:creator>Tomas79</dc:creator>
      <dc:date>2018-11-21T17:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to insert data into Hive from SparkSQL</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/85509#M21363</link>
      <description>&lt;P&gt;Another approach of inserting the data which we are following in our project is not to insert the data in HIVE directly from SPARK instead do the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Read the input csv file in SPARK and do the transformation of the data according to requirement.&lt;/P&gt;&lt;P&gt;2. Save the data back into an output csv file in HDFS&lt;/P&gt;&lt;P&gt;3. Push the data from the output csv into HIVE using HIVE -f or HIVE -e command from shell.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jan 2019 16:07:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-insert-data-into-Hive-from-SparkSQL/m-p/85509#M21363</guid>
      <dc:creator>Aditya</dc:creator>
      <dc:date>2019-01-26T16:07:38Z</dc:date>
    </item>
  </channel>
</rss>

