Hive 中特定列的区别
我正在运行 Hive 071。 我有一个表,有多行,具有相同的列值。
x | y |
---------
1 | 2 |
1 | 3 |
1 | 4 |
2 | 2 |
3 | 2 |
3 | 1 |
我想让 x 列唯一,并删除具有相同 x 值的行;
x | y |
---------
1 | 2 |
2 | 2 |
3 | 2 |
或者
x | y |
---------
1 | 4 |
2 | 2 |
3 | 1 |
两者都很好。
由于 unique 仅适用于 Hive 中的整行,因此我找不到方法来做到这一点。
I am running Hive 071.
I have a table, with mulitple rows, with the same column value.
x | y |
---------
1 | 2 |
1 | 3 |
1 | 4 |
2 | 2 |
3 | 2 |
3 | 1 |
I want to have the x column unique, and remove rows that have the same x val;
x | y |
---------
1 | 2 |
2 | 2 |
3 | 2 |
or
x | y |
---------
1 | 4 |
2 | 2 |
3 | 1 |
are both good.
As distinct works only on the whole row in Hive, I couldn't find a way to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 unique 关键字:
You can use the distinct keyword:
尝试以下查询来获取结果:
select Ax , Ay from (select x , y ,rank() over (partition by x order by y) as returned from testingg)A 其中ranked=1;
try following query to get result :
select A.x , A.y from (select x , y , rank() over ( partition by x order by y) as ranked from testingg)A where ranked=1;