<?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: Delete/update on hadoop  partitioned table  in Hive ? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212414#M66125</link>
    <description>&lt;P&gt;thanks for reply, yep tried to delete using command as below.&lt;/P&gt;&lt;PRE&gt;hive&amp;gt;delete  emp_table where ods='2017_006_30'and id=1;
Usage:delete[FILE|JAR|ARCHIVE]&amp;lt;value&amp;gt;[&amp;lt;value&amp;gt;]
*Query returned non-zero code:1, cause:null&lt;/PRE&gt;&lt;P&gt;Out put got as deleted, actually rows are not deleted from table.&lt;/P&gt;&lt;P&gt;Hive Version:- 1.2.1+&lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2017 11:51:10 GMT</pubDate>
    <dc:creator>shivkumar82015</dc:creator>
    <dc:date>2017-08-07T11:51:10Z</dc:date>
    <item>
      <title>Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212412#M66123</link>
      <description>&lt;PRE&gt;hive&amp;gt; delete from student where ods='2017_006_30' and id=1;
Usage: delete [FILE|JAR|ARCHIVE] &amp;lt;value&amp;gt; [&amp;lt;value&amp;gt;]*
Query returned non-zero code: 1, cause: null&lt;/PRE&gt;&lt;P&gt;I am getting result, however data is not getting deleted from hive table ?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 06:32:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212412#M66123</guid>
      <dc:creator>shivkumar82015</dc:creator>
      <dc:date>2017-08-07T06:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212413#M66124</link>
      <description>&lt;P&gt;Delete/Update in Hive, There are some limitation.&lt;/P&gt;&lt;P&gt;Plz check this link 'https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Delete'&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 09:37:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212413#M66124</guid>
      <dc:creator>youngick</dc:creator>
      <dc:date>2017-08-07T09:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212414#M66125</link>
      <description>&lt;P&gt;thanks for reply, yep tried to delete using command as below.&lt;/P&gt;&lt;PRE&gt;hive&amp;gt;delete  emp_table where ods='2017_006_30'and id=1;
Usage:delete[FILE|JAR|ARCHIVE]&amp;lt;value&amp;gt;[&amp;lt;value&amp;gt;]
*Query returned non-zero code:1, cause:null&lt;/PRE&gt;&lt;P&gt;Out put got as deleted, actually rows are not deleted from table.&lt;/P&gt;&lt;P&gt;Hive Version:- 1.2.1+&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 11:51:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212414#M66125</guid>
      <dc:creator>shivkumar82015</dc:creator>
      <dc:date>2017-08-07T11:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212415#M66126</link>
      <description>&lt;P&gt;Finally, I deleted a row !!!&lt;/P&gt;&lt;P&gt;There are lots of limitations with following link(ex: bucket, orc, set variables, ...)&lt;/P&gt;&lt;P&gt;&lt;A href="https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions#HiveTransactions-Limitations" target="_blank"&gt;https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions#HiveTransactions-Limitations&lt;/A&gt;&lt;/P&gt;&lt;P&gt;set hive.support.concurrency=true; &lt;/P&gt;&lt;P&gt;set hive.enforce.bucketing=true; &lt;/P&gt;&lt;P&gt;set hive.exec.dynamic.partition.mode=nonstrict; &lt;/P&gt;&lt;P&gt;set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager; &lt;/P&gt;&lt;P&gt;create table test_delete (
id int,
name string
) &lt;/P&gt;&lt;P&gt;CLUSTERED BY (id) INTO 2 BUCKETS STORED AS ORC &lt;/P&gt;&lt;P&gt;TBLPROPERTIES ("transactional"="true"); &lt;/P&gt;&lt;P&gt;INSERT INTO TABLE test_delete VALUES (31, 'aaa31'); &lt;/P&gt;&lt;P&gt;INSERT INTO TABLE test_delete VALUES (32, 'aaa32'); &lt;/P&gt;&lt;P&gt;INSERT INTO TABLE test_delete VALUES (33, 'aaa33'); &lt;/P&gt;&lt;P&gt;INSERT INTO TABLE test_delete VALUES (34, 'aaa34'); &lt;/P&gt;&lt;P&gt;INSERT INTO TABLE test_delete VALUES (35, 'aaa35'); &lt;/P&gt;&lt;P&gt;hive&amp;gt; select * from test_delete; &lt;/P&gt;&lt;P&gt;OK &lt;/P&gt;&lt;P&gt;31      aaa31 &lt;/P&gt;&lt;P&gt;32      aaa32 &lt;/P&gt;&lt;P&gt;33      aaa33 &lt;/P&gt;&lt;P&gt;34      aaa34 &lt;/P&gt;&lt;P&gt;35      aaa35 &lt;/P&gt;&lt;P&gt;Time taken: 0.06 seconds, Fetched: 5 row(s) &lt;/P&gt;&lt;P&gt;delete from test_delete where name = 'aaa33'; &lt;/P&gt;&lt;P&gt;hive&amp;gt; select * from test_delete; &lt;/P&gt;&lt;P&gt;OK &lt;/P&gt;&lt;P&gt;32      aaa32 &lt;/P&gt;&lt;P&gt;34      aaa34 &lt;/P&gt;&lt;P&gt;31      aaa31 &lt;/P&gt;&lt;P&gt;35      aaa35 &lt;/P&gt;&lt;P&gt;Time taken: 0.129 seconds, Fetched: 4 row(s)&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 14:13:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212415#M66126</guid>
      <dc:creator>youngick</dc:creator>
      <dc:date>2017-08-07T14:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212416#M66127</link>
      <description>&lt;P&gt;Looks like  its not working for the partitioned tables, pleaes verify the logs.&lt;/P&gt;&lt;PRE&gt;Before Delete :- Counts 
hive&amp;gt; select count(*) from emptable where  ods='2017_06_30' and code!='123';
OK
12
Time taken: 32.57 seconds, Fetched: 1 row(s)&amp;lt;br&amp;gt;&lt;/PRE&gt;
&lt;PRE&gt;Delete Command
hive&amp;gt; set hive.support.concurrency=true;
hive&amp;gt;set hive.enforce.bucketing=true;
hive&amp;gt;set hive.exec.dynamic.partition.mode=nonstrict;
hive&amp;gt;set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
hive&amp;gt; delete emptable where  ods='2017_06_30' and code!='123';
Usage: delete [FILE|JAR|ARCHIVE] &amp;lt;value&amp;gt; [&amp;lt;value&amp;gt;]*
Query returned non-zero code: 1, cause: null



&lt;/PRE&gt;
&lt;PRE&gt;After delete still same recrods :-
hive&amp;gt; select count(*) from emptable where  ods='2017_06_30' and code!='123';
OK
12
Time taken: 26.406 seconds, Fetched: 1 row(s)
&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 12:02:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212416#M66127</guid>
      <dc:creator>shivkumar82015</dc:creator>
      <dc:date>2017-08-08T12:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212417#M66128</link>
      <description>&lt;P&gt;Looks like its not working for the partitioned tables, pleaes verify the logs.&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:30:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212417#M66128</guid>
      <dc:creator>shivkumar82015</dc:creator>
      <dc:date>2017-08-08T13:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212418#M66129</link>
      <description>&lt;P&gt;Try this,&lt;/P&gt;&lt;P&gt;hive&amp;gt; delete emptable where  ods='2017_06_30' and code!='123'; &lt;/P&gt;&lt;P&gt;---&amp;gt; &lt;/P&gt;&lt;P&gt;hive&amp;gt; delete &lt;STRONG&gt;from &lt;/STRONG&gt;emptable where  ods='2017_06_30' and code!='123';&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 16:16:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212418#M66129</guid>
      <dc:creator>youngick</dc:creator>
      <dc:date>2017-08-08T16:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Delete/update on hadoop  partitioned table  in Hive ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212419#M66130</link>
      <description>&lt;P&gt;Finally Worked for Me and did some work around. Steps as below.&lt;/P&gt;&lt;P&gt;1) Create Temp table with same columns.&lt;/P&gt;&lt;P&gt;2) Overwrite table with required row data.&lt;/P&gt;&lt;P&gt;3)Drop Hive partitions and HDFS directory.&lt;/P&gt;&lt;P&gt;4)Insert records for respective partitions and rows.&lt;/P&gt;&lt;P&gt;5) verify the counts.&lt;/P&gt;&lt;PRE&gt;1) hive&amp;gt; select count(*) from emptable where  od='17_06_30' and ccodee=!'123';
OK
27
hive&amp;gt; select count(*) from emptable where  od='17_06_30' and ccodee='123';
OK
7
hive&amp;gt;show create table emptable_tmp; :- Note hdfs location 
&lt;/PRE&gt;&lt;PRE&gt;2)Create table and overwrite with required partitioned data
hive&amp;gt; CREATE  TABLE `emptable_tmp`(
    'rowid` string,PARTITIONED BY (`od` string) 
	ROW FORMAT SERDE
     'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
   STORED AS INPUTFORMAT
     'org.apache.hadoop.mapred.SequenceFileInputFormat';
	 
hive&amp;gt; insert into emptable_tmp partition(od) select * from emptable where od='17_06_30' and ccodee!='123';
         Time taken for adding to write entity : 1
Partition database.emptable_tmp{od=17_06_30} stats: [numFiles=20, numRows=27,totalSize=6216,rawDataSize=5502]
OK

&lt;/PRE&gt;&lt;PRE&gt;3) Drop Partitions from Hive and HDFS directory as well, as this is External table.
hive&amp;gt; alter table emptable drop partition(od='17_06_30');
Dropped the partition od=17_06_30
OK
Time taken: 0.291 seconds
HDFS partition deletion
#hdfs dfs -rm -r /hdfs/location/emptable/ods='17_06_30'
&lt;/PRE&gt;&lt;PRE&gt;4) Insert data for that partition only.

hive&amp;gt; insert into emptable partition(od) select * from emptable_tmp;
Partition database.emptable{ds=17_06_30} stats: [numFiles=66, numRows=20, totalSize=5441469982, rawDataSize=]
OK
Time taken: 27.282 seconds
&lt;/PRE&gt;&lt;PRE&gt;5) Verifying the counts on partitions and respective rows data
1) hive&amp;gt; select count(*) from emptable where  od='17_06_30' and ccodee=!'123';
OK
27
hive&amp;gt; select count(*) from emptable where  od='17_06_30' and ccodee='123';
OK
0&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 17:32:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Delete-update-on-hadoop-partitioned-table-in-Hive/m-p/212419#M66130</guid>
      <dc:creator>shivkumar82015</dc:creator>
      <dc:date>2017-08-08T17:32:37Z</dc:date>
    </item>
  </channel>
</rss>

