<?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: Need to drop a hive partition based on date range (through sub query in Alter statement) in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148443#M52709</link>
    <description>&lt;P&gt;Don't use this method. It will delete all your partitions. No matter you use&lt;/P&gt;&lt;PRE&gt;PARTITION (date &amp;gt;'date1'), PARTITION (date &amp;lt;'date2')&lt;/PRE&gt;&lt;OL&gt;
&lt;/OL&gt;&lt;P&gt;OR&lt;/P&gt;&lt;PRE&gt;PARTITION (date &amp;lt;'date1'), PARTITION (date &amp;gt;'date2')&lt;/PRE&gt;&lt;OL&gt;
&lt;/OL&gt;</description>
    <pubDate>Thu, 13 Dec 2018 12:51:39 GMT</pubDate>
    <dc:creator>lonelybooky</dc:creator>
    <dc:date>2018-12-13T12:51:39Z</dc:date>
    <item>
      <title>Need to drop a hive partition based on date range (through sub query in Alter statement)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148439#M52705</link>
      <description>&lt;P&gt;While i was trying to drop a partition based on date range, i unable to achieve it and below is what i am trying to do&lt;/P&gt;&lt;P&gt;alter table X  drop partition(partdate &amp;lt;= (select max(partdate) as  from Y)); &lt;/P&gt;&lt;P&gt;I am getting error, while i am executing above query -- cannot recognize input near '(' 'select' 'max' in constant&lt;/P&gt;&lt;P&gt;Looks like the alter statement accepts only the constant value rather then a sub-query.&lt;/P&gt;&lt;P&gt;Basicaly - Alter table drop partition ( partdate &amp;lt;= date -- and this date need to fetch from another table).&lt;/P&gt;&lt;P&gt;Any help is appreciated. &lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 08:07:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148439#M52705</guid>
      <dc:creator>PentaReddy</dc:creator>
      <dc:date>2017-01-27T08:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need to drop a hive partition based on date range (through sub query in Alter statement)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148440#M52706</link>
      <description>&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/80073/need-to-drop-a-hive-partition-based-on-date-range.html#"&gt;@Reddy&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/80073/need-to-drop-a-hive-partition-based-on-date-range.html#"&gt;&lt;/A&gt;The commands below work:&lt;/P&gt;&lt;P&gt;Hive does not accept subquery in that DDL clause, but this works:&lt;/P&gt;&lt;PRE&gt;ALTER TABLE myTable DROP PARTITION (date &amp;lt; 'date1') , PARTITION (date &amp;gt;'date2');&lt;/PRE&gt;&lt;P&gt;It needs literals for 'date1' and 'date2'. If you need these to be dynamic then you can use ' --hivevar date1=xxxxx ' for it.&lt;/P&gt;&lt;P&gt;More on that &lt;A href="https://community.hortonworks.com/questions/23731/parameter-in-beeline-script.html"&gt;here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2017 17:42:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148440#M52706</guid>
      <dc:creator>jknulst</dc:creator>
      <dc:date>2017-01-27T17:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need to drop a hive partition based on date range (through sub query in Alter statement)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148441#M52707</link>
      <description>&lt;P&gt;It is not working. It deleted all my partitions. Looks like it first delete partitions below date1 and then it deleted partitions above date 2. Which resulted in total data loss!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 16:48:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148441#M52707</guid>
      <dc:creator>goguladileepkum</dc:creator>
      <dc:date>2017-07-06T16:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need to drop a hive partition based on date range (through sub query in Alter statement)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148442#M52708</link>
      <description>&lt;P&gt;It should be like,&lt;/P&gt;&lt;OL&gt;
&lt;/OL&gt;&lt;P&gt;ALTER TABLE myTable DROP PARTITION (&lt;STRONG&gt;date &amp;gt;'date1'&lt;/STRONG&gt;), PARTITION (&lt;STRONG&gt;date &amp;lt;'date2'&lt;/STRONG&gt;);&lt;/P&gt;,&lt;OL&gt;
&lt;/OL&gt;&lt;P&gt;It should be like &lt;/P&gt;&lt;P&gt;ALTER TABLE myTable DROP PARTITION (&lt;STRONG&gt;date &amp;gt;'date1'&lt;/STRONG&gt;), PARTITION (&lt;STRONG&gt;date&amp;lt;'date2'&lt;/STRONG&gt;);&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 19:05:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148442#M52708</guid>
      <dc:creator>rkarthik2468</dc:creator>
      <dc:date>2017-10-23T19:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need to drop a hive partition based on date range (through sub query in Alter statement)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148443#M52709</link>
      <description>&lt;P&gt;Don't use this method. It will delete all your partitions. No matter you use&lt;/P&gt;&lt;PRE&gt;PARTITION (date &amp;gt;'date1'), PARTITION (date &amp;lt;'date2')&lt;/PRE&gt;&lt;OL&gt;
&lt;/OL&gt;&lt;P&gt;OR&lt;/P&gt;&lt;PRE&gt;PARTITION (date &amp;lt;'date1'), PARTITION (date &amp;gt;'date2')&lt;/PRE&gt;&lt;OL&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 13 Dec 2018 12:51:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148443#M52709</guid>
      <dc:creator>lonelybooky</dc:creator>
      <dc:date>2018-12-13T12:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need to drop a hive partition based on date range (through sub query in Alter statement)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148444#M52710</link>
      <description>&lt;P&gt;To drop partitions with a Range filter, use below syntax. (CDH 5.7, Hive 1.1.0).&lt;/P&gt;&lt;BLOCKQUOTE&gt;ALTER TABLE tableName DROP PARTITION (date &amp;gt;='20190410', date &amp;lt;='20190415');&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Before:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;+-----------------------+--+&lt;/P&gt;&lt;P&gt;|       partition       |&lt;/P&gt;&lt;P&gt;+-----------------------+--+&lt;/P&gt;&lt;P&gt;| date=20190401  |&lt;/P&gt;&lt;P&gt;| date=20190402  |&lt;/P&gt;&lt;P&gt;| date=20190403  |&lt;/P&gt;&lt;P&gt;| date=20190404  |&lt;/P&gt;&lt;P&gt;| date=20190405  |&lt;/P&gt;&lt;P&gt;| date=20190406  |&lt;/P&gt;&lt;P&gt;&lt;U&gt;| date=20190410  |&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;| date=20190411  |&lt;/U&gt;&lt;/P&gt;&lt;P&gt;+-----------------------+--+&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;ALTER TABLE tableName DROP PARTITION (date &amp;gt;='20190410', date &amp;lt;='20190415');&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;AFTER:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;+-----------------------+--+&lt;/P&gt;&lt;P&gt;|       partition       |&lt;/P&gt;&lt;P&gt;+-----------------------+--+&lt;/P&gt;&lt;P&gt;| date=20190401  |&lt;/P&gt;&lt;P&gt;| date=20190402  |&lt;/P&gt;&lt;P&gt;| date=20190403  |&lt;/P&gt;&lt;P&gt;| date=20190404  |&lt;/P&gt;&lt;P&gt;| date=20190405  |&lt;/P&gt;&lt;P&gt;| date=20190406  |&lt;/P&gt;&lt;P&gt;+-----------------------+--+&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 22:55:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Need-to-drop-a-hive-partition-based-on-date-range-through/m-p/148444#M52710</guid>
      <dc:creator>shivamohanmp</dc:creator>
      <dc:date>2019-04-27T22:55:15Z</dc:date>
    </item>
  </channel>
</rss>

