如何使用hive/spark sql生成大型数据集?

dz6r00yl  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(417)

e、 g.生成序号在1到1g之间的1g记录。

z4iuyo4d

z4iuyo4d1#

创建分区种子表

create table seed (i int)
partitioned by (p int)

用序号在0到999之间的1k条记录填充种子表。
每个记录都被插入到不同的分区中,因此位于不同的hdfs目录中,更重要的是位于不同的文件中。
附笔。
需要以下集合

set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=1000;
set hive.hadoop.supports.splittable.combineinputformat=false;
set hive.input.format=org.apache.hadoop.hive.ql.io.HiveInputFormat;
insert into table seed partition (p)
select  i,i 
from    (select 1) x lateral view posexplode (split (space (999),' ')) e as i,x

生成包含1g记录的表。
种子表中的每个1k记录都位于不同的文件中,并且由不同的容器读取。
每个容器生成1百万条记录。

create table t1g
as
select  s.i*1000000 + e.i + 1  as n
from    seed s lateral view posexplode (split (space (1000000-1),' ')) e as i,x

相关问题