HIVE 中的减号查询 [英] Minus query in HIVE

查看:26
本文介绍了HIVE 中的减号查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

减号查询在 HIVE 中似乎不起作用.

Minus query seems to not work in HIVE.

尝试过:

select x from abc 
minus 
select x from bcd ; 

我做错了还是没有为 HIVE 定义减去查询?如果是这样,有没有其他方法可以得到这个结果?

Am I doing this wrong or minus query isn't defined for HIVE? If so, is there any other way to get the result for this?

推荐答案

HQL 似乎不支持 MINUS 运算符.看到这个相关的,虽然有点旧,资源:

It does not appear that HQL supports the MINUS operator. See this relevant, albeit a bit old, resource:

http://www.quora.com/Apache-Hive/What-are-the-biggest-feature-gaps-between-HiveQL-and-SQL

你想做的事情可以用 LEFT JOINNOT EXISTS 来完成:

What you want to do can be done with a LEFT JOIN or NOT EXISTS:

SELECT x
FROM abc
LEFT JOIN bcd
ON abc.x = bcd.x
WHERE bcd.x IS NULL

根据下面的评论,不支持 NOT EXISTS.

Per comments below, NOT EXISTS is not supported.

SELECT x 
FROM abc
WHERE NOT EXISTS (SELECT x FROM bcd)

这篇关于HIVE 中的减号查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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