<?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 can you make the row_id the primary key in a hive table?,how can you make row_id the primary key in HIVE? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163330#M53580</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/493/icocio.html" nodeid="493"&gt;@icocio&lt;/A&gt;&lt;P&gt; Thank you&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 16:43:15 GMT</pubDate>
    <dc:creator>nandini_bhattac</dc:creator>
    <dc:date>2017-02-09T16:43:15Z</dc:date>
    <item>
      <title>How can you make the row_id the primary key in a hive table?,how can you make row_id the primary key in HIVE?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163328#M53578</link>
      <description />
      <pubDate>Tue, 07 Feb 2017 14:42:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163328#M53578</guid>
      <dc:creator>nandini_bhattac</dc:creator>
      <dc:date>2017-02-07T14:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can you make the row_id the primary key in a hive table?,how can you make row_id the primary key in HIVE?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163329#M53579</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/15865/nandinibhattacharjee.html" nodeid="15865"&gt;@Nandini Bhattacharjee&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You might want to take a look at the following HCC post&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/22321/can-i-create-primary-key-in-hive-table-i-saw-in-tb.html" target="_blank"&gt;https://community.hortonworks.com/questions/22321/can-i-create-primary-key-in-hive-table-i-saw-in-tb.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 21:50:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163329#M53579</guid>
      <dc:creator>icocio</dc:creator>
      <dc:date>2017-02-07T21:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can you make the row_id the primary key in a hive table?,how can you make row_id the primary key in HIVE?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163330#M53580</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/493/icocio.html" nodeid="493"&gt;@icocio&lt;/A&gt;&lt;P&gt; Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 16:43:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163330#M53580</guid>
      <dc:creator>nandini_bhattac</dc:creator>
      <dc:date>2017-02-09T16:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can you make the row_id the primary key in a hive table?,how can you make row_id the primary key in HIVE?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163331#M53581</link>
      <description>&lt;P&gt;Hi, I found another way of doing this:&lt;/P&gt;&lt;P&gt;1. I first loaded my data set in HDFS. The data set contained the following columns: rwid, ctrname, clndrdate and clndrmonth.&lt;/P&gt;&lt;P&gt;Note that column rwid had no values.&lt;/P&gt;&lt;P&gt;2. Then i created an external table that maps to this data set in hdfs&lt;/P&gt;&lt;P&gt;CREATE EXTERNAL TABLE IF NOT EXISTS calendar(rwid int, ctrname string, clndrdate DATE, clndrmonth string ) 
COMMENT 'Calendar for Non Business Days' 
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
location '&amp;lt;location of my file in hdfs&amp;gt;'; &lt;/P&gt;&lt;P&gt;3. I created an ORC &lt;/P&gt;&lt;P&gt;CREATE TABLE IF NOT EXISTS calendar_nbd(rwid int, ctrname string, clndrdate DATE, clndrmonth string )  
COMMENT 'Calendar for Non Business Days' 
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS ORC;&lt;/P&gt;&lt;P&gt;4. The last step is most important. I used row_number() over() in the insert overwrite query. This automatically updated the rwid column with the row number.&lt;/P&gt;&lt;P&gt;
insert overwrite table calendar_nbd 
select row_number() over () as rwid, ctrname,clndrdate, clndrmonth from calendarnonbusdays;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 19:20:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-you-make-the-row-id-the-primary-key-in-a-hive-table/m-p/163331#M53581</guid>
      <dc:creator>nandini_bhattac</dc:creator>
      <dc:date>2017-02-17T19:20:22Z</dc:date>
    </item>
  </channel>
</rss>

