Hive Aapche 设置为事务表(ACID)This command is not allowed on an ACID table xxx with a non-ACID transaction

Apache Hive中默认的创建的表为非事务表,如果需要将表设置为事务表需要修改以下参数:

参数配置文件为hive-site.xml

<property>
    <name>hive.support.concurrency</name>
    <value>true</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>

<property>
    <name>hive.create.as.insert.only</name>
    <value>true</value>
</property>

<property>
    <name>hive.optimize.acid.meta.columns</name>
    <value>true</value>
</property>

当表为事务表时,如果使用非事务的参数去执行SQL,会报如下错误:

Error: Error while compiling statement: FAILED: SemanticException [Error 10265]: This command is not allowed on an ACID table test_acid with a non-ACID transaction manager. Failed command: create table test_acid