<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hadoop Archives - Big Data Processing</title>
	<atom:link href="https://bigdataproc.com/tag/hadoop/feed/" rel="self" type="application/rss+xml" />
	<link>https://bigdataproc.com/tag/hadoop/</link>
	<description>Big Data Solution for GCP, AWS, Azure and on-prem</description>
	<lastBuildDate>Sat, 14 Jan 2023 16:12:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.2</generator>
	<item>
		<title>When to use lateral view explode in hive</title>
		<link>https://bigdataproc.com/when-to-use-lateral-view-explode-in-hive/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=when-to-use-lateral-view-explode-in-hive</link>
					<comments>https://bigdataproc.com/when-to-use-lateral-view-explode-in-hive/#comments</comments>
		
		<dc:creator><![CDATA[Gaurang]]></dc:creator>
		<pubDate>Wed, 12 Dec 2018 19:13:48 +0000</pubDate>
				<category><![CDATA[Hadoop]]></category>
		<category><![CDATA[hive]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[Hive]]></category>
		<guid isPermaLink="false">http://allabouthadoop.net/?p=111</guid>

					<description><![CDATA[<p>if you have a table with one or more column with array datatype&#160;&#160;and if you want it to expand into multiple rows, you can use&#8230;</p>
<div class="more-link-wrapper"><a class="more-link" href="https://bigdataproc.com/when-to-use-lateral-view-explode-in-hive/">Continue reading<span class="screen-reader-text">When to use lateral view explode in hive</span></a></div>
<p>The post <a rel="nofollow" href="https://bigdataproc.com/when-to-use-lateral-view-explode-in-hive/">When to use lateral view explode in hive</a> appeared first on <a rel="nofollow" href="https://bigdataproc.com">Big Data Processing </a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>if you have a table with one or more column with<strong> array datatype&nbsp;</strong>&nbsp;and if you want it to expand into multiple rows, you can use lateral view explode function.&nbsp;</p>



<p>Let&#8217;s consider we have following table, where one employee has multiple phone numbers which are stores as part of array (list).&nbsp;</p>



<table class="wp-block-table"><tbody><tr><td><strong>emp_name</strong></td><td><strong>phone_numbers</strong></td></tr><tr><td>user1</td><td>[&#8220;546-487-3384&#8243;,&#8221;383-767-2238&#8221;]</td></tr><tr><td>user2</td><td>[&#8220;373-384-1192&#8243;,&#8221;374-282-1289&#8243;,&#8221;332-453-5566&#8221;]</td></tr></tbody></table>



<p>However as a output if we want to convert this Array (list) into multiple rows, we can use lateral view explode function a mentioned below&nbsp;</p>



<pre class="lang:sql theme:twilight" title="when to use lateral view explode in hive">select emp_name, phone_number 
from 
    temp.test_laterla_view_explode
lateral view explode(phone_numbers) p as phone_number
</pre>



<p>This will generate the output as mentioned below</p>



<table class="wp-block-table"><tbody><tr><td><strong>emp_name</strong></td><td><strong>phone_number</strong></td></tr><tr><td>user2</td><td>373-384-1192</td></tr><tr><td>user2</td><td>374-282-1289</td></tr><tr><td>user2</td><td>332-453-5566</td></tr><tr><td>user1</td><td>546-487-3384</td></tr><tr><td>user1</td><td>383-767-2238</td></tr></tbody></table>
<p>The post <a rel="nofollow" href="https://bigdataproc.com/when-to-use-lateral-view-explode-in-hive/">When to use lateral view explode in hive</a> appeared first on <a rel="nofollow" href="https://bigdataproc.com">Big Data Processing </a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://bigdataproc.com/when-to-use-lateral-view-explode-in-hive/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Update Hive Table</title>
		<link>https://bigdataproc.com/update-hive-table/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=update-hive-table</link>
					<comments>https://bigdataproc.com/update-hive-table/#comments</comments>
		
		<dc:creator><![CDATA[Gaurang]]></dc:creator>
		<pubDate>Wed, 05 Sep 2018 00:30:34 +0000</pubDate>
				<category><![CDATA[Hadoop]]></category>
		<category><![CDATA[hive]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[Hive]]></category>
		<guid isPermaLink="false">http://allabouthadoop.net/?p=11</guid>

					<description><![CDATA[<p>Hive is a append only database and so update and delete is not supported on hive external and managed table.&#160; From hive version 0.14 the&#8230;</p>
<div class="more-link-wrapper"><a class="more-link" href="https://bigdataproc.com/update-hive-table/">Continue reading<span class="screen-reader-text">Update Hive Table</span></a></div>
<p>The post <a rel="nofollow" href="https://bigdataproc.com/update-hive-table/">Update Hive Table</a> appeared first on <a rel="nofollow" href="https://bigdataproc.com">Big Data Processing </a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Hive is a append only database and so update and delete is not supported on hive external and managed table.&nbsp;</p>



<p>From hive version 0.14 the have started a new feature called <strong>transactional.&nbsp;</strong> Which allows to have ACID properties for a particular hive table and allows to delete and update. but let&#8217;s keep the transactional table for any other posts.&nbsp;</p>



<p>Here let&#8217;s discuss how to update hive table which is not transaction, either external or managed ( External table couldn&#8217;t be transactional).</p>



<p>Chances are if you have tried to update the hive table, external or managed (non transactional), you might have got below errors, depends on your hive version.</p>



<pre class="lang:mysql theme:twilight"> select * from temp.test_udpate;
+-----------------+-------------------+--+
| test_update.id  | test_update.name  |
+-----------------+-------------------+--+
| 1               | test user 1       |
| 2               | test user 2       |
| 2               | test user 3       |
+-----------------+-------------------+--+
delete from temp.test1 where id=1;
Error: Error while compiling statement: FAILED:
SemanticException [Error 10297]: Attempt to do update or
delete on table temp.test1 that does not use an
AcidOutputFormat or is not bucketed (state=42000,code=10297)</pre>



<p>Then the question is how to update or delete a record in hive table?</p>



<h2 class="wp-block-heading">Deleting Records in Hive Table</h2>



<p>Deleting rerecords is easy,&nbsp; you can use <strong>insert overwrite </strong>Syntax for this. Let&#8217;s says we want to delete a record from above hive table which has name as &#8220;test user 3&#8221;.&nbsp; Then we need to select all the records which does not have name as &#8220;test user 3&#8221; and overwrite into same table.&nbsp;</p>



<pre class="lang:mysql theme:twilight"> 
insert overwrite table temp.test_update \
select * from temp.test_update \ 
where name = "test user 3";
</pre>



<p></p>



<h2 class="wp-block-heading">Update Records in Hive Table</h2>



<p>updating the record consist of three steps as mentioned below. Let&#8217;s say in your <strong>test.update&nbsp;</strong>table we want to update the <strong>id</strong>&nbsp;to<strong> 3&nbsp;</strong> for all the records which has name as <strong>&#8220;test user 3&#8221;</strong></p>



<h3 class="wp-block-heading">Create a temporary table which has updated record</h3>



<pre class="lang:mysql theme:twilight"> 
create temporary table temp.test \
as select 3 as id, name from temp.test_update \
where name="test user 3";
</pre>



<h3 class="wp-block-heading">Delete the records which you want to update from original table</h3>



<pre class="lang:mysql theme:twilight">  insert overwrite table temp.test_update \
select * from temp.test_update \
where name="test user 3";
</pre>



<h3 class="wp-block-heading">Insert the Updated Record(s)</h3>



<pre class="lang:mysql theme:twilight"> insert into table temp.test_update select * from temp.test;

</pre>
<p>The post <a rel="nofollow" href="https://bigdataproc.com/update-hive-table/">Update Hive Table</a> appeared first on <a rel="nofollow" href="https://bigdataproc.com">Big Data Processing </a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://bigdataproc.com/update-hive-table/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
