Hive transactions

Below is just a simple example of hive transactions. These are very useful on slowly changing type 1 dimension tables for which you do not wish to retain history, but only the most recent value of the row. The table must be bucketed, and the transactional=true property must be set on the table as shown below.

0: jdbc:hive2://localhost:10000/brierley> create table t(c int)   clustered by (c) into 10 buckets stored as orc tblproperties('transactional'='true');
No rows affected (0.077 seconds)
0: jdbc:hive2://localhost:10000/brierley> insert into table t values(1);
INFO  : Tez session hasn't been created yet. Opening session

…snip…

INFO  :
INFO  : Table brierley.t stats: [numFiles=11, numRows=1, totalSize=2871, rawDataSize=0]
0: jdbc:hive2://localhost:10000/brierley> select * from t;
+------+--+
| t.c  |
+------+--+
| 2    |
+------+--+
1 row selected (0.172 seconds)
0: jdbc:hive2://localhost:10000/brierley>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.