hive的多插语句可以只扫描一次数据源表,往多张目标表插入数据,减少对数据源表的扫描次数。
from table1
insert overwrite/into table2 select [cols,…] where cond2
insert overwrite/into table3 select [cols,…] where cond3
insert overwrite/into table4 select [cols,…] where cond4
…
;
测试数据:
drop table if exists default.test001;
create table if not exists default.test001(
s_name string,
s_course map<string, int>
) comment 'name_course'
row format delimited
fields terminated by '\t'
collection items terminated by ','
map keys terminated by ':';
drop table if exists default.test002;
create table if not exists default.test002(
s_course string,
c_cnt int
) comment 'course_count';
drop table if exists default.test003;
create table if not exists default.test003(
s_name string,