Python全系列 教程
3567个小节阅读:5931.1k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
select * from bucket_table tablesample(bucket x out of y on columns);
tablesample语法:
tablesample(bucket x out of y on columns)
x:表示从哪个bucket开始抽取数据
y:必须为该表总bucket数的倍数或因子
columns:分桶的列名
当表总bucket数为32时
共抽取2(32/16)个bucket的数据,抽取第3、第19(3+16)个bucket的数据
共抽取4(32/8)个bucket的数据,抽取:3,11,19,27
共抽取1/8(32/256)个bucket的数据,抽取第3个bucket的1/8数据。
该描述在hive1.2.1的版本中如上所描述的一致(和hive官网中的说法一致)
但是在hive3.1.2的版本中使用时,有bug。
当表总bucket数为4时
抽取1和3号桶中的数据:
xxxxxxxxxx
select * from psnbucket tablesample(bucket 1 out of 2 on age);
注意:x<=y,不能是x>y。如果x>y将会出现如下的错误提示:
xxxxxxxxxx
hive> select * from psnbucket tablesample(bucket 5 out of 4 on age);
FAILED: SemanticException [Error 10061]: Numerator should not be bigger than denominator in sample clause for table psnbucket
总结:分区是分目录存储,分桶是将表中的数据分文件存储。