【问题标题】:Update on Hive 1.2.1Hive 1.2.1 更新
【发布时间】:2017-03-14 14:37:21
【问题描述】:

我的表名“records”带有描述:

hive> desc records;
OK
year                    string                                      
temperature             int                                         
quality                 int  

根据Apache documentation 可以在 Hive 1.2.1 中进行更新(0.14.0 之后的版本)

我尝试了更新命令并得到了下面提到的错误:

hive> update records
    > set quality=8
    > where year='2000';
FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations.

我到底错过了什么? 是代码还是表格不满足任何条件(限制)?

【问题讨论】:

    标签: hadoop hive hiveql


    【解决方案1】:

    仅允许对 ORC 文件格式进行更新。此外,您必须在执行更新或删除之前设置一些属性。

    客户端

    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;
    

    设置后创建具有所需属性的表

    CREATE TABLE test_result
    (run_id VARCHAR(100), chnl_txt_map_key INT)
    clustered by (run_id) into 1 buckets 
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY '\t'
    STORED AS orc tblproperties ("transactional"="true" );
    

    现在您可以对此表执行更新或插入。如果您希望仅在 adhoc 基础上执行 DML 操作,则可以单独在会话中设置所有上述属性,而不是在 hive-site.xml 文件中设置服务器端属性。

    【讨论】:

    • 我在 ahdoc 的基础上尝试,所以在同一个会话中设置配置更改。但它仍然会引发同样的错误。
    【解决方案2】:

    在 hive-site.xml 中添加以下属性,

      <property>
        <name>hive.support.concurrency</name>
        <value>true</value>
      </property>
      <property>
        <name>hive.enforce.bucketing</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.initiator.on</name>
        <value>true</value>
      </property>
      <property>
        <name>hive.compactor.worker.threads</name>
        <value>1</value>
      </property>
    

    并重新启动配置单元服务器

    检查此链接-> http://sanjivblogs.blogspot.in/2014/12/transactions-are-available-in-hive-014.html 希望这会有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      • 2020-11-30
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-12
      相关资源
      最近更新 更多