hive - Hive 中 rand() 函数的精度?
问题描述
如果我的表有很多行,比如数百亿行,是否会select rand() from table
为两行给出两个相同的结果?
解决方案
rand()
hive 中函数的返回类型是double
. double 的精度大约在 -10^308 到 10^308 的范围内。所以 rand() 返回重复结果的机会几乎为零。
在具有 150 亿行的 hive 上测试了以下查询。
select r, count(*)
from (
select rand() as r from <table name>
) as a
group by r
having count(*)>1;
结果是No Rows Found
。这表示rand()
没有返回重复的行。
检查来自 Hive wiki 的关于浮点精度的链接。
推荐阅读
- c# - xUnit 断言两个值相等且具有一定的容差
- latex - 设置没有框架标题的投影仪框架属性
- azure - Azure 数据工厂 foreach 活动步长支持
- python-2.7 - 修剪文本文件中的行
- javascript - 如何修复 FabricJS 缩放的多边形剪裁偏移
- bpf - 在 libseccomp 中,什么是 scmp_filter_ctx?它是用来做什么的?
- angular-cli - 本地主机在 LAN 上不可访问
- android - 请求权限对话框未出现 Android 6.0.1
- r - R jsonlite:以定义的结构导出数据框
- .htaccess - 想要将特定的通配符 url 永久重定向到某个域 url。所以我需要.htaccess 规则,任何人都可以帮我解决这个问题