hive2.1.insert、update、delete操作测试

hive2.1.insert、update、delete操作测试

在HIve缺省配置设置中,转换管理器不支持update跟delete操作。

若要Hive支持update操作跟delete操作,必须额外再配置一些东西,详细见:

https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions

Configuration

Minimally, these configuration parameters must be set appropriately to turn on transaction support in Hive:

Client Side

  • hive.support.concurrency – true
  • hive.enforce.bucketing – true (Not required as of Hive 2.0)
  • hive.exec.dynamic.partition.mode – nonstrict
  • hive.txn.manager – org.apache.hadoop.hive.ql.lockmgr.DbTxnManager

Server Side (Metastore)

  • hive.compactor.initiator.on – true (See table below for more details)
  • hive.compactor.worker.threads – a positive number on at least one instance of the Thrift metastore service

具体示例:

CREATE TABLE src22 (key STRING COMMENT 'default', value STRING COMMENT 'default')clustered by (key)  into 10 buckets  stored as orc  TBLPROPERTIES('transactional'='true') ;


FROM src
    INSERT INTO TABLE src22 SELECT src.key, src.value;


DELETE FROM src22 WHERE KEY="321";

虽然Hive可以执行update,delete操作,但是由于性能实在是较差,或者需要大量优化,或者需要在未来版本进行系统部分重构优化才可。


你可能感兴趣的:(hive)