Remay
Big Data
How to work with ACID tables in hive
2 fevereiro, 2016
0

If we have to work with hive tables in the transactional mode we have to use two characteristics below:

– bucketing
– table property transactional=true
– Ambari – Hive – Configs – ACID Transactions = ON

 

We can test with these commands:


--Sets for update the engine and vectorized processing
set hive.execution.engine=tez;
set hive.vectorized.execution.enabled=true;
set hive.vectorized.execution.reduce.enabled=true;


--------------------------
--Target table to create
--------------------------
drop table tbl1;
create table tbl1
(
f1 int,
f2 string
)
clustered by (f2) into 1 buckets
stored as orc tblproperties ("transactional"="true");


----------------------------------------------------
--Simple load using the transactional way
----------------------------------------------------
insert into table tbl1 values (1, 'line1');
insert into table tbl1 values (2, 'line2');
insert into table tbl1 values (3, 'line3');


--------------------------
--First Result
--------------------------
Select * from tbl1;


1 line1
2 line2
3 line3
Time taken: 0.798 seconds, Fetched: 3 row(s)


--------------------------
--Simple update
--------------------------
update tbl1 set
f1 = 200
where f1 = 2;


--------------------------
--Second Result
--------------------------
select * from tbl1 ;


1 line1
200 line2
3 line3


--------------------------
--Simple delete
--------------------------
delete from tbl1 where f1 = 3;


--------------------------
--Third Result
--------------------------
select * from tbl1 ;
1 line1
200 line2

HDP 2.2 – How to create a surrogate key on hive

<div class="addthis_toolbox addth...

Read more

HDP 2.2 Sandbox – How To Fix the error JA002: Unauthorized connection for super-user: oozie from IP 127.0.0.1

<div class="addthis_toolbox addth...

Read more

Existem 0 comentários

twitter

REDES SOCIAIS