hive update delete
来源:互联网 发布:java友盟别名推送demo 编辑:程序博客网 时间:2024/06/05 15:57
Hive 从0.14开始支持事务,即支持update和delete操作。事务操作有严格的要求,在写这篇文章时用的1.1.0有以下限制
- BEGIN, COMMIT, and ROLLBACK are not yet supported. All language operations are auto-commit. The plan is to support these in a future release.
- Only ORC file format is supported in this first release. The feature has been built such that transactions can be used by any storage format that can determine how updates or deletes apply to base records (basically, that has an explicit or implicit row id), but so far the integration work has only been done for ORC.
- By default transactions are configured to be off. See the Configuration section below for a discussion of which values need to be set to configure it.
- Tables must be bucketed to make use of these features. Tables in the same system not using transactions and ACID do not need to be bucketed.
- At this time only snapshot level isolation is supported. When a given query starts it will be provided with a consistent snapshot of the data. There is no support for dirty read, read committed, repeatable read, or serializable. With the introduction of BEGIN the intention is to support snapshot isolation for the duration of transaction rather than just a single query. Other isolation levels may be added depending on user requests.
The existing ZooKeeper and in-memory lock managers are not compatible with transactions. There is no intention to address this issue. See Basic Design below for a discussion of how locks are stored for transactions.
经过多次试验,才最终实现,具体步骤如下:
1、设置相关参数
set hive.support.concurrency=true;set hive.enforce.bucketing=true;set hive.exec.dynamic.partition.mode=nonstrict;set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;set hive.compactor.initiator.on=true;set hive.compactor.worker.threads=1;
2、创建表
use tmp;drop table cuixz;create table cuixz (log_id int,agg_status tinyint)CLUSTERED BY (log_id) INTO 1 BUCKETSstored as orcTBLPROPERTIES ("transactional"="true","NO_AUTO_COMPACTION"="true"); --目前大小写敏感
3、测试
hive> insert into cuixz select log_id, agg_status from stg_dp.s_log_file;hive> select * from cuixz where log_id = 3480224;OK3480224 NULLTime taken: 0.213 seconds, Fetched: 1 row(s)hive> update cuixz set agg_status = 1 where log_id = 3480224;hive> select * from cuixz where log_id = 3480224;OK3480224 1Time taken: 0.144 seconds, Fetched: 1 row(s)hive> select * from cuixz where log_id = 3480224;hive> select * from cuixz where log_id = 3480224;OKTime taken: 0.351 seconds
注:update\delete后面的where表达式不支持子查询
参考
https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/Drop/TruncateTable
0 0
- hive update delete
- hive实现update与delete
- 开启hive数据表的update delete
- 开启hive数据表的update delete
- 让Hive支持行级insert、update、delete
- hive如何配置支持事务及insert、update、delete
- 让Hive支持行级insert、update、delete
- 让Hive支持行级insert、update、delete
- CDH5.4.10 在Hive上执行Update,Delete操作报错Attempt to do update or delete using transaction manager that doe
- delete update sql join
- update delete left join
- Insert Update Delete Select
- Delete,Update与Join
- Insert , Update , Delete 触发器
- select update delete
- 视图Update Delete
- Insert,Update,Delete操作
- Hibernate之update&delete
- javascript正整数,输入验证,字节长度计算
- 解决root用户无法登录mysql
- SCCM 2012安装教程(Part1)
- 抚摸那条船——彭晓东
- Spring 配置的2个常见问题
- hive update delete
- akka 2.3.11 实例
- uploadify各种问题解决
- ios一键打包
- JVM性能调优
- Mongodb模糊查询
- Ubuntu下将现有的文件打包成deb包
- 如何提升MySQL批量插入的效率
- Cordys 事物处理Demo