我是靠谱客的博主 迷人仙人掌,这篇文章主要介绍Hive中随机抽样,现在分享给大家,希望可以做个参考。

在给用户推荐表中,由于待推荐的话题数太多,所以随机抽样检测。

user_recs_categroy
userinfoid 用户ID
simtopicid 话题ID

复制代码
1
2
3
4
5
select a1.userinfoid,a1.simtopicid from (select a1.userinfoid,a1.simtopicid,row_number()over(partition by a1.userinfoid order by rand()) rn from user_recs_categroy a1) a1 where rn<=5 limit 20;

结果显示
第一次:

复制代码
1
2
3
4
5
6
2 15850 2 16024 2 16986 2 16166 2 16383

第二次:

复制代码
1
2
3
4
5
6
2 17029 2 16547 2 15878 2 16044 2 15742

最后

以上就是迷人仙人掌最近收集整理的关于Hive中随机抽样的全部内容,更多相关Hive中随机抽样内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部