<?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 select the last table from a list of hive tables? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105475#M33438</link>
    <description>&lt;P&gt;
	&lt;A rel="user" href="https://community.cloudera.com/users/1505/alexraj84.html" nodeid="1505"&gt;@Alex Raj&lt;/A&gt; You can also create a script using 2 commands&lt;/P&gt;&lt;OL&gt;
	
&lt;LI&gt;Execute "show tables; " to get all tables&lt;/LI&gt;&lt;LI&gt;For each table execute "desc formatted &amp;lt; database &amp;gt;.&amp;lt; table_name &amp;gt;"  . The output contains a field CreateTime. &lt;/LI&gt;&lt;LI&gt;use CreateTime field to find the latest table.&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Thu, 30 Jun 2016 19:52:11 GMT</pubDate>
    <dc:creator>pankaj_singh</dc:creator>
    <dc:date>2016-06-30T19:52:11Z</dc:date>
    <item>
      <title>How to select the last table from a list of hive tables?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105473#M33436</link>
      <description>&lt;P&gt;I have a list of hive tables and want to select the last table for performing some query. Here is what I use to get the list of similar hive tables.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;show tables 'test_temp_table*';
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It displays the below result&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;test_temp_table_1
test_temp_table_2
test_temp_table_3
test_temp_table_4
test_temp_table_5
test_temp_table_6
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I need to run some query on test_temp_table_6. I can do this using shell script by writing the output to a temp file and reading the last value from it but is there a simple way using hive query to get the last table that has the maximum number at the end?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 13:15:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105473#M33436</guid>
      <dc:creator>Alexraj84</dc:creator>
      <dc:date>2016-06-30T13:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the last table from a list of hive tables?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105474#M33437</link>
      <description>&lt;P&gt;Finally, I got the answer from Stackoverflow and wanted to propagate here. There isn't seems to be a straight way to get the last table name however the answer works just using a single line of shell script including the hive query. Here is it.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;last_table=$(hive -e "show tables 'test_temp_table*';" | sort -r | head -n1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jun 2016 19:13:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105474#M33437</guid>
      <dc:creator>Alexraj84</dc:creator>
      <dc:date>2016-06-30T19:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the last table from a list of hive tables?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105475#M33438</link>
      <description>&lt;P&gt;
	&lt;A rel="user" href="https://community.cloudera.com/users/1505/alexraj84.html" nodeid="1505"&gt;@Alex Raj&lt;/A&gt; You can also create a script using 2 commands&lt;/P&gt;&lt;OL&gt;
	
&lt;LI&gt;Execute "show tables; " to get all tables&lt;/LI&gt;&lt;LI&gt;For each table execute "desc formatted &amp;lt; database &amp;gt;.&amp;lt; table_name &amp;gt;"  . The output contains a field CreateTime. &lt;/LI&gt;&lt;LI&gt;use CreateTime field to find the latest table.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Thu, 30 Jun 2016 19:52:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-select-the-last-table-from-a-list-of-hive-tables/m-p/105475#M33438</guid>
      <dc:creator>pankaj_singh</dc:creator>
      <dc:date>2016-06-30T19:52:11Z</dc:date>
    </item>
  </channel>
</rss>

