Hive表中Partition的创建
作用:
在Hive Select查询中一般会扫描整个表内容,会消耗很多时间做没必要的工作。有时候只需要扫描表中关心的一部分数据,在对应的partition里面去查找就可以,减少查询时间。
1. 创建表
]# cat create_rating_table_p.sql
create external table rating_table_p
(userId STRING,
movieId STRING,
rating STRING
)
partitioned by (dt STRING)
row format delimited fields terminated by '\t'
lines terminated by '\n';
2. 导入数据
LOAD DATA LOCAL INPATH '/usr/local/hive/test/hive_test_3/ml-latest-small/2009-12.data' OVERWRITE INTO TABLE rating_table_p partition(dt='2009-12');
LOAD DATA LOCAL INPATH '/usr/local/hive/test/hive_test_3/ml-latest-small/2003-09.data' OVERWRITE INTO TABLE rating_table_p partition(dt='2003-09');
3. HDFS上面查看,会在以表名为文件夹下面,有两个以时间命名的文件夹,对应日期数据存在对应文件夹下面
]$ hdfs dfs -ls /user/hive/warehouse/rating_table_p
Found items
drwxrwxrwx - hadoop supergroup -- : /user/hive/warehouse/rating_table_p/dt=-
drwxrwxrwx - hadoop supergroup -- : /user/hive/warehouse/rating_table_p/dt=-
4. Hive表中查询
hive> select userid, dt from rating_table_p where dt='2009-12' limit ;
OK
-
-
-
-
-
-
-
-
-
-
5. 删除分区
alter table rating_table_p drop if exists partition(dt='2003-10');
6.添加分区
alter table rating_table_p add if not exists partition(dt='2003-10');
Hive表中Partition的创建的更多相关文章
- 将DataFrame数据如何写入到Hive表中
1.将DataFrame数据如何写入到Hive表中?2.通过那个API实现创建spark临时表?3.如何将DataFrame数据写入hive指定数据表的分区中? 从spark1.2 到spark1.3 ...
- 使用spark对hive表中的多列数据判重
本文处理的场景如下,hive表中的数据,对其中的多列进行判重deduplicate. 1.先解决依赖,spark相关的所有包,pom.xml spark-hive是我们进行hive表spark处理的关 ...
- sqoop导入数据到hive表中的相关操作
1.使用sqoop创建表并且指定对应的hive表中的字段的数据类型,同时指定该表的分区字段名称 sqoop create-hive-table --connect "jdbc:oracle: ...
- 20.采集项目流程篇之清洗数据绑定到hive表中
先启动hive 在mydb2这个数据库中创建表: create external table mydb2.access(ip string,day string,url string,upflow s ...
- 11.把文本文件的数据导入到Hive表中
先在hive里面创建一个表 create table mydb2.t3(id int,name string,age int) row format delimited fields terminat ...
- 使用spark将内存中的数据写入到hive表中
使用spark将内存中的数据写入到hive表中 hive-site.xml <?xml version="1.0" encoding="UTF-8" st ...
- 如何将hive表中的数据导出
近期经常将现场的数据带回公司测试,所以写下该文章,梳理一下思路. 1.首先要查询相应的hive表,比如我要将c_cons这张表导出,我先查出hive中是否有这张表. 查出数据,证明该表在hive中存在 ...
- 批量导入数据到hive表中:假设我有60张主子表如何批量创建导入数据
背景:根据业务需要需要把60张主子表批量入库到hive表. 创建测试数据: def createBatchTestFile(): Unit = { to ) { val sWriter = new P ...
- spark读取mongodb数据写入hive表中
一 环境: spark-: hive-; scala-; hadoop--cdh-; jdk-1.8; mongodb-2.4.10; 二.数据情况: MongoDB数据格式{ "_i ...
随机推荐
- 用ELK打造可视化集中式日志
原文链接:https://yq.aliyun.com/articles/57420 摘要: Elk是Elastic search, Logstash和Kibana三者的简称. Elastic sear ...
- Centos6.5安装pip命令以及中途遇到的问题
一.Centos6.5安装pip命令时可能会遇到的问题 1.安装setuptools模块时python安装模块时报异常:Compression requires the (missing) zlib ...
- 利用 background 和 filter 模糊指定区域
背景知识:background-size: cover;,background-attachment:fixed;,filter:blur() 难题: 通常,我们会通过filter:blur()去实现 ...
- JavaEE Cookie HttpSession 学习笔记
1. 会话管理概述 1.1 什么是会话 好比一次通话.打开浏览器,点击多次链接(发出多次请求和收到多次的响应),关闭浏览器,这个过程就是一次会话. 有功能 可以 文件 新建会话 1.2 解决的问题是 ...
- C#控制台窗口居中显示(转)
private struct RECT { public int left, top, right, bottom; } [DllImport("kernel32.dll", Se ...
- ajax跨域获取返回值
js代码 $.ajax({ async:false, url: 'https://***/api/prepareApi.getDanMu?sqlMapId=findBarrage', // 跨域URL ...
- Linux下pip使用国内源
pip国内的一些镜像 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/si ...
- 计蒜客 31447 - Fantastic Graph - [有源汇上下界可行流][2018ICPC沈阳网络预赛F题]
题目链接:https://nanti.jisuanke.com/t/31447 "Oh, There is a bipartite graph.""Make it Fan ...
- codeforces 782B - The Meeting Place Cannot Be Changed
time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standa ...
- 解决下载的CHM文件无法显示网页问题
问题症状:打开CHM文件,左边目录齐全,可右边边框里却是无法显示网页. 解决方法:方法一:修改注册表1)新建一个文本文件2)添加如下内容:REGEDIT4[HKEY_LOCAL_MACHINE\SOF ...