Thursday, 6 October 2016

How to Work with ACID Functionality in Hive-1.2.1

Pre-Requisites of Hive Project:
hadoop-2.6.0
hive-1.2.1
java-1.7

NOTE: Make sure that install all the above components


Follow the Below Steps to Enable ACID Functionality in HIVE


1. Add the below properties in "hive-site.xml" file

<property>
<name>hive.in.test</name>
<value>true</value>
</property>
<property>
<name>hive.support.concurrency</name>
<value>true</value>
</property>
<property>
<name>hive.enforce.bucketing</name>
<value>true</value>
</property>
<property>
<name>hive.compactor.initiator.on</name>
<value>true</value>
</property>
<property>
<name>hive.exec.dynamic.partition.mode</name>
<value>nonstrict</value>
</property>
<property>
<name>hive.txn.manager</name>
<value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
</property>
<property>
<name>hive.compactor.worker.threads</name>
<value>2</value>
</property>



















2. Execute the "hive" command



















3. Execute the "show databases;" command



















4. Execute the "exit;" command





















5. Update the below property in "hive-site.xml" file

<property>
<name>hive.in.test</name>
<value>false</value>
</property>





















6. Execute the "hive" command




















7. Execute the "show databases;" command


















8. CREATE HIVE TABLE WITH CLUSTERED BY, ORC, TBLPROPERTIES

CREATE TABLE IF NOT EXISTS student
( name string, id int, course string, year int )
CLUSTERED BY (name) INTO 4 BUCKETS
STORED AS ORC
LOCATION '/hive/kalyan/student'
TBLPROPERTIES ('transactional' = 'true');




9. LIST OF ALL TABLES IN HIVE


show tables;


10. DISPLAY THE DATA FROM HIVE TABLE

select * from student;




11. INSERT THE DATA INTO HIVE TABLE

INSERT INTO TABLE student VALUES
('arun', 1, 'mca', 1),
('anil', 2, 'mca', 1),
('sudheer', 3, 'mca', 2),
('santosh', 4, 'mca', 2);




12. DISPLAY THE DATA FROM HIVE TABLE


select * from student;




13. UPDATE THE DATA INTO HIVE TABLE


UPDATE student
SET year = 3, course = 'mech'
WHERE id = 4 ;



14. DISPLAY THE DATA FROM HIVE TABLE


select * from student;




15. DELETE THE DATA FROM HIVE TABLE


DELETE FROM student WHERE name = 'anil';




16. DISPLAY THE DATA FROM HIVE TABLE


select * from student;



Share this article with your friends.
Related Posts Plugin for WordPress, Blogger...