如何始终将配置单元查询文件输出限制在单个文件中
how to constraint hive query file output to be in a single file always
我使用下面的查询创建了一个配置单元 table,并使用下面提到的第二个查询每天向这个 table 插入数据
create EXTERNAL table IF NOT EXISTS DB.efficacy
(
product string,
TP_Silent INT,
TP_Active INT,
server_date date
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION 'hdfs://hdfsadlproduction/user/DB/Report/efficacy';
Insert INTO DB.efficacy
select
product,
SUM(CASE WHEN verdict = 'TP_Silent' THEN 1 ELSE 0 END ),
SUM(CASE WHEN verdict = 'TP_Active' THEN 1 ELSE 0 END ) ,
current_date()
from
DB.efficacy_raw
group by
product
;
问题是,每天当我执行插入查询时,它基本上都会在 hadoop FS 中创建一个新文件。我希望每天的查询输出仅附加到同一个文件中,但 Hadoop FS 以下列方式包含文件。
000000_0、000000_0_copy_1、000000_0_copy_2
我使用了以下配置单元设置:-
SET hive.execution.engine=mr;
SET tez.queue.name=${queueName};
SET mapreduce.job.queuename=${queueName};
SET mapreduce.map.memory.mb = 8192;
SET mapreduce.reduce.memory.mb = 8192;
SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
SET hive.exec.parallel = true;
SET hive.exec.parallel.thread.number = 2;
SET mapreduce.input.fileinputformat.split.maxsize=2048000000;
SET mapreduce.input.fileinputformat.split.minsize=2048000000;
SET mapreduce.job.reduces = 20;
SET hadoop.security.credential.provider.path=jceks://hdfs/user/efficacy/s3-access/efficacy.jceks;
set hive.vectorized.execution.enabled=false;
set hive.enforce.bucketmapjoin=false;
set hive.optimize.bucketmapjoin.sortedmerge=false;
set hive.enforce.sortmergebucketmapjoin=false;
set hive.optimize.bucketmapjoin=false;
set hive.exec.dynamic.partition.mode=nostrict;
set hive.exec.compress.intermediate=false;
set hive.exec.compress.output=false;
**set hive.exec.reducers.max=1;**
我是 Hive 和 Hadoop 时代的初学者,请原谅。任何帮助将不胜感激
注意:- 我使用的是 Hadoop 2.7.3.2.5.0.55-1
我没有看到任何可用的直接机制或配置单元设置,它们会在查询结束时自动合并所有小文件。存储为文本文件的文件目前不支持小文件的串联。
根据 "leftjoin" 在我的 post 中的评论,我创建了 ORC 格式的 table,然后使用 CONCATENATE 配置单元查询将所有小文件合并为一个大文件。
然后我使用下面的配置单元查询将数据从这个大的 ORC 文件导出到单个文本文件,并且可以用这个导出的文本文件完成我的任务。
hive#INSERT OVERWRITE DIRECTORY '<Hdfs-Directory-Path>'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
SELECT * FROM default.foo;
礼貌:- https://community.hortonworks.com/questions/144122/convert-orc-table-data-into-csv.html
我使用下面的查询创建了一个配置单元 table,并使用下面提到的第二个查询每天向这个 table 插入数据
create EXTERNAL table IF NOT EXISTS DB.efficacy
(
product string,
TP_Silent INT,
TP_Active INT,
server_date date
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION 'hdfs://hdfsadlproduction/user/DB/Report/efficacy';
Insert INTO DB.efficacy
select
product,
SUM(CASE WHEN verdict = 'TP_Silent' THEN 1 ELSE 0 END ),
SUM(CASE WHEN verdict = 'TP_Active' THEN 1 ELSE 0 END ) ,
current_date()
from
DB.efficacy_raw
group by
product
;
问题是,每天当我执行插入查询时,它基本上都会在 hadoop FS 中创建一个新文件。我希望每天的查询输出仅附加到同一个文件中,但 Hadoop FS 以下列方式包含文件。 000000_0、000000_0_copy_1、000000_0_copy_2
我使用了以下配置单元设置:-
SET hive.execution.engine=mr;
SET tez.queue.name=${queueName};
SET mapreduce.job.queuename=${queueName};
SET mapreduce.map.memory.mb = 8192;
SET mapreduce.reduce.memory.mb = 8192;
SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
SET hive.exec.parallel = true;
SET hive.exec.parallel.thread.number = 2;
SET mapreduce.input.fileinputformat.split.maxsize=2048000000;
SET mapreduce.input.fileinputformat.split.minsize=2048000000;
SET mapreduce.job.reduces = 20;
SET hadoop.security.credential.provider.path=jceks://hdfs/user/efficacy/s3-access/efficacy.jceks;
set hive.vectorized.execution.enabled=false;
set hive.enforce.bucketmapjoin=false;
set hive.optimize.bucketmapjoin.sortedmerge=false;
set hive.enforce.sortmergebucketmapjoin=false;
set hive.optimize.bucketmapjoin=false;
set hive.exec.dynamic.partition.mode=nostrict;
set hive.exec.compress.intermediate=false;
set hive.exec.compress.output=false;
**set hive.exec.reducers.max=1;**
我是 Hive 和 Hadoop 时代的初学者,请原谅。任何帮助将不胜感激
注意:- 我使用的是 Hadoop 2.7.3.2.5.0.55-1
我没有看到任何可用的直接机制或配置单元设置,它们会在查询结束时自动合并所有小文件。存储为文本文件的文件目前不支持小文件的串联。
根据 "leftjoin" 在我的 post 中的评论,我创建了 ORC 格式的 table,然后使用 CONCATENATE 配置单元查询将所有小文件合并为一个大文件。
然后我使用下面的配置单元查询将数据从这个大的 ORC 文件导出到单个文本文件,并且可以用这个导出的文本文件完成我的任务。
hive#INSERT OVERWRITE DIRECTORY '<Hdfs-Directory-Path>'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
SELECT * FROM default.foo;
礼貌:- https://community.hortonworks.com/questions/144122/convert-orc-table-data-into-csv.html