【发布时间】:2023-03-29 08:25:01
【问题描述】:
我使用的工作区是使用 Hive 1.1.0 和 CDH 5.5.4 设置的。我做了一个查询,结果是 22 个分区。保存在此分区目录中的文件始终是唯一的,并且可以从 20MB 到 700MB 不等。
据我了解,这与查询过程中使用的reducer数量有关。假设我希望每个分区有 5 个文件而不是 1 个,我使用这个命令:
set mapreduce.job.reduces=5;
这将使系统在第 1 阶段使用 5 个 reduce 任务,但会在第 2 阶段自动切换到 1 个 reducer(在编译时自动确定)。根据我的阅读,这是由于在选择减速器数量时编译器比配置更重要。似乎有些任务不能“并行化”,只能由一个进程或reducer任务完成,所以系统会自动确定。
代码:
insert into table core.pae_ind1 partition (project,ut,year,month)
select ts,date_time, if(
-- m1
code_ac_dcu_m1_d1=0
and (min(case when code_ac_dcu_m1_d1=1 then ts end ) over (partition by ut
order by ts rows between 1 following and 1000 following)-ts) <= 15,
min(case when code_ac_dcu_m1_d1=1 then ts end ) over (partition by ut order
by ts rows between 1 following and 1000 following)-ts,NULL) as
t_open_dcu_m1_d1,
if( code_ac_dcu_m1_d1=2
and (min(case when code_ac_dcu_m1_d1=3 then ts end ) over (partition by ut
order by ts rows between 1 following and 1000 following)-ts) <= 15,
min(case when code_ac_dcu_m1_d1=3 then ts end ) over (partition by ut order
by ts rows between 1 following and 1000 following)-ts, NULL) as
t_close_dcu_m1_d1,
project,ut,year,month
from core.pae_open_close
where ut='902'
order by ut,ts
这会导致最后有巨大的文件。我想知道是否有办法将此结果文件拆分为较小的文件(最好按大小限制)。
【问题讨论】:
-
order by ut,ts?