<?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: mapping data from spark into hive table in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242026#M203829</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/102377/gsatya0825.html" nodeid="102377"&gt;@Satya G&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Read the &lt;STRONG&gt;CSV file with header &lt;/STRONG&gt;as described here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.DataFrameReader" target="_blank"&gt;https://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.DataFrameReader&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Once you are able to read the &lt;STRONG&gt;csv file&lt;/STRONG&gt; with header then use &lt;STRONG&gt;.select&lt;/STRONG&gt; method and select the col's as&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;#pyspark:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;df= spark.read.csv(&amp;lt;file&amp;gt;).option("header", "true") //read the csv with header
df1=df.select("A","B","C","D") //select the columns in an order
df1.write.mode("&amp;lt;overwrite/append&amp;gt;").saveAsTable("&amp;lt;db_name&amp;gt;.&amp;lt;tab_name&amp;gt;")&lt;/PRE&gt;</description>
    <pubDate>Sat, 12 Jan 2019 10:40:53 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2019-01-12T10:40:53Z</dc:date>
    <item>
      <title>mapping data from spark into hive table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242025#M203828</link>
      <description>&lt;P&gt;Spark is getting data with a header showing col's A,C,D,B and the data under it. Next day we get the same data like this Col's B,D,A,C and then the next day we get data like col's A,C,B,D and so on randomly. Now we have to put this data in a hive table with col's as A,B,C,D. Can any one suggest me an idea how to write this script in spark?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 14:22:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242025#M203828</guid>
      <dc:creator>gsatya0825</dc:creator>
      <dc:date>2019-01-11T14:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: mapping data from spark into hive table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242026#M203829</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/102377/gsatya0825.html" nodeid="102377"&gt;@Satya G&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Read the &lt;STRONG&gt;CSV file with header &lt;/STRONG&gt;as described here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.DataFrameReader" target="_blank"&gt;https://spark.apache.org/docs/2.1.0/api/python/pyspark.sql.html#pyspark.sql.DataFrameReader&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Once you are able to read the &lt;STRONG&gt;csv file&lt;/STRONG&gt; with header then use &lt;STRONG&gt;.select&lt;/STRONG&gt; method and select the col's as&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;#pyspark:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;df= spark.read.csv(&amp;lt;file&amp;gt;).option("header", "true") //read the csv with header
df1=df.select("A","B","C","D") //select the columns in an order
df1.write.mode("&amp;lt;overwrite/append&amp;gt;").saveAsTable("&amp;lt;db_name&amp;gt;.&amp;lt;tab_name&amp;gt;")&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Jan 2019 10:40:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242026#M203829</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-01-12T10:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: mapping data from spark into hive table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242027#M203830</link>
      <description>&lt;P&gt;@Shu Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 06:18:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/mapping-data-from-spark-into-hive-table/m-p/242027#M203830</guid>
      <dc:creator>gsatya0825</dc:creator>
      <dc:date>2019-01-14T06:18:43Z</dc:date>
    </item>
  </channel>
</rss>

