赞
踩
Hivesql里,为了提高查询效率,我们可以将通用的功能模块微服务化,除了可以使用 with…as 这种优化方式外,本文记录另外一种方式: from() insert into
from test1
insert overwrite table test2
partition (age)
select name, address, school, age
insert overwrite table test3
select name,address
多表插入的关键点在于将所要执行查询的表语句 “from 表名”,放在最开头位置。
注意 :
1、这是一个优化,可以减少表的扫描,从而减少 JOB 中 MR的 STAGE 数量,达到优化的目的。
下面的错误信息和hive的版本有关,测试使用hive1.1.0报错,hive 3.0版本语法是支持插入同一张表的
2、使用多插入时,如果目标表是普通表,不能插入相同的表,否则报错:
FAILED: SemanticException [Error 10087]: The same output cannot be present multiple times
3、如果目标表是分区表,不能向相同分区插入数据,否则报错
FAILED: SemanticException [Error 10087]: The same output cannot be present multiple times
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。