<?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 Hive : Drop Partitions : How to drop Date partitions containing non-date values? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160024#M57201</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Below is the hive table partitions(three level partitions) I have. This table is a MANAGED table(internal table). First two partitions are incorrect partitions created due to a bug in my insert hive script. Later some days, i found this and i want to drop these two partitions somehow. I tried multiple ALTER table DROP partitions, but nothing worked for me. How to drop these partitions? Can anyone please help me?&lt;/P&gt;&lt;P&gt;Column - reporting_date is of DATE data type. This column got inserted with '${hiveconf:reporting_date}' value instead of '2016-12-09'. This created a problem. &lt;/P&gt;&lt;P&gt;Column - source_system is of STRING data type&lt;/P&gt;&lt;P&gt;Column - break_type is of STRING data type.&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; show partitions crhs_fmtrade_break;
reporting_date=$%7Bhiveconf%3Areporting_date}/source_system=MXG/break_type=Destination
reporting_date=$%7Bhiveconf%3Areporting_date}/source_system=MXG/break_type=Source
reporting_date=2016-12-09/source_system=BTS/break_type=Data
reporting_date=2016-12-09/source_system=BTS/break_type=Destination
...

hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='${hiveconf:reporting_date}');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='${hiveconf:reporting_date}\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='\r${hiveconf:reporting_date}\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='\r${hiveconf:reporting_date}');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='$%7Bhiveconf%3Areporting_date}\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='$\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)

&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Mar 2017 14:45:53 GMT</pubDate>
    <dc:creator>gnanasekaran_g</dc:creator>
    <dc:date>2017-03-16T14:45:53Z</dc:date>
    <item>
      <title>Hive : Drop Partitions : How to drop Date partitions containing non-date values?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160024#M57201</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Below is the hive table partitions(three level partitions) I have. This table is a MANAGED table(internal table). First two partitions are incorrect partitions created due to a bug in my insert hive script. Later some days, i found this and i want to drop these two partitions somehow. I tried multiple ALTER table DROP partitions, but nothing worked for me. How to drop these partitions? Can anyone please help me?&lt;/P&gt;&lt;P&gt;Column - reporting_date is of DATE data type. This column got inserted with '${hiveconf:reporting_date}' value instead of '2016-12-09'. This created a problem. &lt;/P&gt;&lt;P&gt;Column - source_system is of STRING data type&lt;/P&gt;&lt;P&gt;Column - break_type is of STRING data type.&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; show partitions crhs_fmtrade_break;
reporting_date=$%7Bhiveconf%3Areporting_date}/source_system=MXG/break_type=Destination
reporting_date=$%7Bhiveconf%3Areporting_date}/source_system=MXG/break_type=Source
reporting_date=2016-12-09/source_system=BTS/break_type=Data
reporting_date=2016-12-09/source_system=BTS/break_type=Destination
...

hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='${hiveconf:reporting_date}');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='${hiveconf:reporting_date}\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='\r${hiveconf:reporting_date}\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='\r${hiveconf:reporting_date}');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='$%7Bhiveconf%3Areporting_date}\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)
hive&amp;gt; alter table crhs_fmtrade_break drop partition(reporting_date='$\r');
FAILED: SemanticException Unexpected unknown partitions for (reporting_date = null)

&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 14:45:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160024#M57201</guid>
      <dc:creator>gnanasekaran_g</dc:creator>
      <dc:date>2017-03-16T14:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hive : Drop Partitions : How to drop Date partitions containing non-date values?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160025#M57202</link>
      <description>&lt;P&gt;You could accomplish this by temporarily changing the partitioning column type to string, see below:&lt;/P&gt;&lt;PRE&gt;-- Change the column type to string
alter table crhs_fmtrade_break partition column (reporting_date string);
-- Drop the offending partitions
alter table crhs_fmtrade_break drop partition(reporting_date='$%7Bhiveconf%3Areporting_date}');
...
-- Change the column type back to date
alter table crhs_fmtrade_break partition column (reporting_date date)&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 00:04:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160025#M57202</guid>
      <dc:creator>deepesh1</dc:creator>
      <dc:date>2017-03-17T00:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Hive : Drop Partitions : How to drop Date partitions containing non-date values?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160026#M57203</link>
      <description>&lt;P&gt;thank you Deepesh. It works for me.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 17:53:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160026#M57203</guid>
      <dc:creator>gnanasekaran_g</dc:creator>
      <dc:date>2017-03-21T17:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hive : Drop Partitions : How to drop Date partitions containing non-date values?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160027#M57204</link>
      <description>&lt;P&gt;But this is not a suitable solution for production environment&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2017 16:53:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/160027#M57204</guid>
      <dc:creator>jack0188</dc:creator>
      <dc:date>2017-08-21T16:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Hive : Drop Partitions : How to drop Date partitions containing non-date values?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/331168#M57205</link>
      <description>&lt;P&gt;I found other simple solution for this issue,&lt;/P&gt;&lt;P&gt;Simply find faulty partition from partition list by using command.&lt;/P&gt;&lt;P&gt;show partitions table table_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then rename the faulty partition to some other name in correct format of your partition.&lt;/P&gt;&lt;P&gt;In my case, I used&lt;/P&gt;&lt;P&gt;ALTER table table_name partition&lt;BR /&gt;(date_flag='2021-11-25_bak') rename to partition (date_flag='2021-01-01');&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 10:11:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-Drop-Partitions-How-to-drop-Date-partitions-containing/m-p/331168#M57205</guid>
      <dc:creator>Shahrukh</dc:creator>
      <dc:date>2021-11-29T10:11:14Z</dc:date>
    </item>
  </channel>
</rss>

