<?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: Copying the Hive External table  from one database to another database. in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286767#M212638</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72521"&gt;@Uppal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great that worked out better for you, did you r&lt;SPAN&gt;un&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF6600"&gt;MSCK REPAIR TABLE table_name;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;on the target table?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;f you found this answer addressed your initial question, please take a moment to login and click "accept" on the answer. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Happy hadooping&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jan 2020 15:47:48 GMT</pubDate>
    <dc:creator>Shelton</dc:creator>
    <dc:date>2020-01-02T15:47:48Z</dc:date>
    <item>
      <title>Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286095#M212217</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got a request to copy one of the large hive external table that has&amp;nbsp;72883 partitions from one database to another database.&amp;nbsp; &amp;nbsp;I am new to the Hive database so I need your help in copying that table.&amp;nbsp; I have done the following steps so far and not sure about next step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do I need to add those&amp;nbsp;72883 partitions manually or is there another way to add those partitions to the target table.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your early response is very much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steps:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; created the external table in new databases with the same definition of the source table,but with different location.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Copy the CSV files of source table location&amp;nbsp; to target table location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;~Suresh D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 16:49:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286095#M212217</guid>
      <dc:creator>Uppal</dc:creator>
      <dc:date>2019-12-20T16:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286145#M212240</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72521"&gt;@Uppal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best way to duplicate a partitioned table in Hive&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create the new target table with the schema from the old table&amp;nbsp; the &lt;STRONG&gt;describe formatted&lt;/STRONG&gt; could help with the SQL&lt;/LI&gt;&lt;LI&gt;Use &lt;FONT color="#FF6600"&gt;hadoop fs -cp&lt;/FONT&gt; to copy all the partitions from source to the target table&lt;/LI&gt;&lt;LI&gt;Run &lt;FONT color="#FF6600"&gt;MSCK REPAIR TABLE table_name;&lt;/FONT&gt; on the target table&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 14:47:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286145#M212240</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2019-12-21T14:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286719#M212605</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72521"&gt;@Uppal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any updates on this thread.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jan 2020 19:06:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286719#M212605</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2020-01-01T19:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286764#M212636</link>
      <description>&lt;P&gt;Thank you for following up on this. &amp;nbsp; Followed the below steps to copy the Hive external table successfully. &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Created the target external table in new databases with the same definition of the source table, but with different location. &amp;nbsp;&amp;nbsp; Extracted the definition of the source table with "&lt;SPAN&gt;&lt;STRONG&gt;show create table &amp;lt;Hive External&amp;nbsp; source table&lt;/STRONG&gt;&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Copy the CSV files of source table location&amp;nbsp; to target table location with "&lt;SPAN&gt;&lt;STRONG&gt;hadoop fs -cp&lt;/STRONG&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; Then added the partitions 72,883 partitions with the below Command.&amp;nbsp; I had to come up with a script for 72,833 partitions though. &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "&lt;STRONG&gt;&lt;SPAN&gt;ALTER TABLE &amp;lt;Hive External Target Table&amp;gt; ADD PARTITION &amp;lt;Partition Name&amp;gt;&lt;FONT face="&amp;quot;Courier New&amp;quot;" color="#001000"&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;FONT face="&amp;quot;Courier New&amp;quot;"&gt; &amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#001000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#001000"&gt;Regards&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#001000"&gt;Suresh D&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 15:05:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286764#M212636</guid>
      <dc:creator>Uppal</dc:creator>
      <dc:date>2020-01-02T15:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286767#M212638</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72521"&gt;@Uppal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great that worked out better for you, did you r&lt;SPAN&gt;un&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF6600"&gt;MSCK REPAIR TABLE table_name;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;on the target table?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;f you found this answer addressed your initial question, please take a moment to login and click "accept" on the answer. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Happy hadooping&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 15:47:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286767#M212638</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2020-01-02T15:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286773#M212642</link>
      <description>&lt;P&gt;Hi Shelton,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not run&amp;nbsp; "&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#ff6600"&gt;MSCK REPAIR TABLE table_name; "&lt;/FONT&gt;&lt;SPAN&gt; on the target table .&amp;nbsp; Not sure if it is needed.&amp;nbsp; Why we have to run that command.&amp;nbsp; My target table is working fine without running that command.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;~Suresh D&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 16:56:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286773#M212642</guid>
      <dc:creator>Uppal</dc:creator>
      <dc:date>2020-01-02T16:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286774#M212643</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72521"&gt;@Uppal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great if all went well we usually&amp;nbsp;run &lt;STRONG&gt;msck&lt;/STRONG&gt; repair table daily once you have loaded a new partition in HDFS location.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Why&amp;nbsp; you need to run msck Repair table statement every time after each ingestion?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hive stores a list of partitions for each table in its metastore. If, however, new partitions are directly added to HDFS , the metastore (and hence Hive) will not be aware of these partitions unless the user runs either of below ways to add the newly add partitions.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;msck&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;will add metadata about partitions to the Hive metastore for partitions for which such metadata doesn't already exist&lt;BR /&gt;If you will find the need remember to do that&amp;nbsp; else accept the answer and close the thread :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:06:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286774#M212643</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2020-01-02T17:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286775#M212644</link>
      <description>&lt;P&gt;Thank you Shelton for sharing.&amp;nbsp; I do not know about it. &amp;nbsp; I will run this command instead of adding the partitions with alter table command next time. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;&lt;P&gt;Suresh D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:15:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286775#M212644</guid>
      <dc:creator>Uppal</dc:creator>
      <dc:date>2020-01-02T17:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copying the Hive External table  from one database to another database.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286777#M212646</link>
      <description>&lt;P&gt;Hi Shelton,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did find a note to add the partitions in another way. &amp;nbsp; Are you aware of it? &amp;nbsp; if so, do you see any issues with it. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;~Suresh D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;&lt;A href="https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.4/using-hiveql/content/hive-automate-msck.html" target="_blank" rel="noopener"&gt;https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.4/using-hiveql/content/hive-automate-msck.html&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;H1&gt;Automate partition discovery and repair&lt;/H1&gt;&lt;DIV class="body taskbody"&gt;&lt;P class="shortdesc"&gt;Hive automatically and periodically discovers discrepancies in partition metadata in the Hive metastore and corresponding directories on the file system, and then performs synchronization. Automating this operation for log data or data in Spark and Hive catalogs is especially helpful.&lt;/P&gt;&lt;P class="p"&gt;The discover.partitions table property enables and disables synchronization of the file system with partitions. In external partitioned tables, this property is enabled (true) by default when you create the table using Hive in HDP 3.1.4 and later. To a legacy external table (created using an earlier version of Hive), add discover.partitions to the table properties to enable partition discovery. By default, the discovery and synchronization of partitions occurs every 5 minutes, but you can configure the frequency as shown in this task.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN class="ph cmd"&gt;Assuming you have an external table created using a version of Hive that does not support partition discovery, enable partition discovery for the table.&lt;/SPAN&gt;&lt;DIV class="itemgroup stepxmp"&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;ALTER&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;TABLE&lt;/SPAN&gt; exttbl &lt;SPAN class="hljs-keyword"&gt;SET&lt;/SPAN&gt; TBLPROPERTIES (&lt;SPAN class="hljs-string"&gt;'discover.partitions'&lt;/SPAN&gt; = &lt;SPAN class="hljs-string"&gt;'true'&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="ph cmd"&gt;Set synchronization of partitions to occur every 10 minutes expressed in seconds: In Ambari &amp;gt; Hive &amp;gt; Configs, set metastore.partition.management.task.frequency to 600.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 02 Jan 2020 18:57:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Copying-the-Hive-External-table-from-one-database-to-another/m-p/286777#M212646</guid>
      <dc:creator>Uppal</dc:creator>
      <dc:date>2020-01-02T18:57:24Z</dc:date>
    </item>
  </channel>
</rss>

