1

我想将简单查询插入配置单元表;

我使用以下代码创建表create table t(id int, f1 String, f2 int);并尝试插入insert into t values (1, '123', 1);

创建了一个任务,但没有执行。

Query ID = hadoop_20200518194705_4ec47375-e5e8-4d33-80d8-ed183aacb0c2
Total jobs = 3
Launching Job 1 out of 3
Number of reduce tasks determined at compile time: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapreduce.job.reduces=<number>
Starting Job = job_1589556481112_0007, Tracking URL = http://hadoop_hose:8088/proxy/application_1589556481112_0007/
Kill Command = /home/hadoop/hadoop-3.1.3/bin/mapred job  -kill job_1589556481112_0007

我究竟做错了什么?

UPD:来自 GUI 的列表:在此处输入图像描述

1

4

1 回答 1

0

您应该查看 Hive 中的 ACID 和事务。您可以点击此链接:

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

Hive 事务管理器应设置为 DbTxnManager

SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;

我们需要启用并发

SET hive.support.concurrency=true;

一旦我们设置了上述属性,我们应该能够将数据插入到任何表中。对于更新和删除,表应该被分桶并且文件格式需要是 ORC 或任何符合 ACID 的格式。我们还需要将表属性事务设置为 true

TBLPROPERTIES ('transactional'='true');

举个例子

查看属性

# REVIEW PROPERTIES
$ cd /etc/hive/conf
$ grep -i txn hive-site.xml
$ hive -e "SET;" | grep -i txn
$ beeline -u jdbc:hive2://localhost:10000

SET hive.txn.manager;
hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager;

SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;

SET hive.support.concurrency=true;

SET hive.enforce.bucketing;
SET hive.enforce.bucketing=true;

SET hive.exec.dynamic.partition.mode;
hive.exec.dynamic.partition.mode=strict

SET hive.exec.dynamic.partition.mode=nonstrict;

SET hive.compactor.initiator.on;
SET hive.compactor.initiator.on=true;
-- A positive number
SET hive.compactor.worker.threads;
SET hive.compactor.worker.threads=1;

CREATE TABLE orders_transactional (
  order_id INT,
  order_date STRING,
  order_customer_id INT,
  order_status STRING
) CLUSTERED BY (order_id) INTO 8 BUCKETS
STORED AS ORC
TBLPROPERTIES("transactional"="true");

INSERT INTO orders_transactional VALUES
(1, '2013-07-25 00:00:00.0', 1000, 'COMPLETE');

INSERT INTO orders_transactional VALUES
(2, '2013-07-25 00:00:00.0', 2001, 'CLOSED'),
(3, '2013-07-25 00:00:00.0', 1500, 'PENDING'),
(4, '2013-07-25 00:00:00.0', 2041, 'PENDING'),
(5, '2013-07-25 00:00:00.0', 2031, 'COMPLETE');

UPDATE orders_transactional
  SET order_status = 'COMPLETE'
WHERE order_status = 'PENDING';

DELETE FROM orders_transactional
WHERE order_status <> 'COMPLETE';

SELECT *
FROM orders_transactional;
于 2020-05-19T09:32:27.803 回答