[英]How to generate a large data set using hive / spark-sql?
例如,生成1G記錄,其序號在1到1G之間。
創建分區的種子表
create table seed (i int)
partitioned by (p int)
在種子表中填充1K條記錄,其序號在0到999之間。
每個記錄都將插入到不同的分區中,因此位於不同的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記錄都在不同的文件上,並且正在由不同的容器讀取。
每個容器生成1M條記錄。
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.