温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

hive分区表如何创建

发布时间:2021-12-10 11:04:17 来源:亿速云 阅读:226 作者:小新 栏目:大数据

小编给大家分享一下hive分区表如何创建,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

      HIVE把表组织成“分区”,这是一种根据“分区列”的值对表进行粗略划分的机制,使用分区可以加快数据分片的查询速度。

      表或分区可以进一步分为“桶”。它会为数据提供额外的结构以获得更高效的查询处理。

  1. 创建分区表

CREATE TABLE bills_detail (msgid STRING,time STRING,spid STRING,opid STRING,spcode STRING,result STRING) 
PARTITIONED BY (dt STRING,type STRING) 
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'

  表结构

hive> desc bills_detail;
OK
msgid                   string                                      
time                    string                                      
spid                    string                                      
opid                    string                                      
spcode                  string                                      
result                  string                                      
dt                      string                                      
type                    string                                      
                 
# Partition Information          
# col_name              data_type               comment             
                 
dt                      string                                      
type                    string

  2.导入数据

load data local inpath '/home/hive/201601notify.txt' into table bills_detail partition(dt='201601',type='notifySmsDeliveryReceipt');
load data local inpath '/home/hive/201601sendsms.txt' into table bills_detail partition(dt='201601',type='sendSms');

hive中数据实际路径:

/apps/hive/warehouse/bills_detail/dt=201601/type=sendSms/201601sendsms.txt

3.查询数据

hive> select * from bills_detail where dt='201601' and type='sendSms' limit 10;

以上是“hive分区表如何创建”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI