插入到 hive 中不存在的地方 [英] insert into where not exists in hive

查看:32
本文介绍了插入到 hive 中不存在的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 ansi sql 中此等效项的 hive 语法

I need the hive syntax for this equivalent in ansi sql

insert into tablea
(id)
select id 
from tableb
where id not in (select id from tablea)

因此 tablea 不包含重复项,并且只插入了 tableb 中的新 ID.

so tablea contains no duplicates and only new ids from tableb are inserted.

推荐答案

使用左外连接和 tableA.id 为空的过滤器:

Use left outer join with a filter that the tableA.id is null:

insert overwrite into tableA (id)
select b.id from tableB b left outer join tableA a
 on a.id = b.id
where a.id is null

这篇关于插入到 hive 中不存在的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆