
Hive
hive知识点
嘉平11
这个作者很懒,什么都没留下…
展开
-
内部表和外部表区别
一、外部表的创建、load、删除1.文件在本地而不是在hdfs的时候1.1 建表时指定location(1)建表并load数据create external table exTable28 (id int,str string) row format delimited fields terminated by ' ' location '/zgm/test/'; load data local inpath '/zgm2/exe28' into table exTable28;.原创 2020-08-25 13:25:07 · 5120 阅读 · 1 评论 -
Hive中建立HBase的映射表
CREATE EXTERNAL TABLE userPhoto(uid string ,tag string ,tagweight double )ROW FORMAT SERDE'org.apache.hadoop.hive.hbase.HBaseSerDe'STORED BY'org.apache.hadoop.hive.hbase.HBaseStorageHandler'W...原创 2020-03-23 19:10:40 · 501 阅读 · 0 评论 -
hql的优化,
一、求学生选的每门课都及格了的学生selecta.*from student2 ajoin(select b.sidfrom sc2 b group by b.sid having min(score)>60) con a.sid=c.sid;两个job taken: 84.528 seconds,select a.* from student2 a join s...原创 2020-03-13 13:38:17 · 173 阅读 · 0 评论 -
Hive笔记——影评项目
一、因为元数据的字段之间用::分割,所以我们使用shell进行一下清洗,将::都转换成逗号vi change1.sh#!/bin/bashsed "s/::/,/g" /zgm/movies.dat>/zgm/movies2.datsed "s/::/,/g" /zgm/ratings.dat>/zgm/ratings2.datsed "s/::/,/...原创 2020-03-02 22:37:00 · 844 阅读 · 0 评论 -
Hive执行顺序
探究一下hql的执行顺序from … on … join … where … group by … having … select … distinct … order by … limit之前有个疑惑:explain select sid,min(score) as msfrom sc2 where sid>10group by sidhaving ms>60...原创 2020-02-29 22:37:25 · 800 阅读 · 0 评论 -
PV、UV的几种写法
一、HQL写法uv:count(distinct)太影响性能,以下为改进:selecttmp.shop,count(1) as uvfrom(select user_id,shop from second_visit group by user_id,shop)tmpgroup by shop;pvselect shop,count(uid) from secon...原创 2020-02-19 15:38:00 · 877 阅读 · 0 评论 -
HQL练习_02,经典sql50题
题目Student(Sid,Sname,Sage,Ssex)学生表Sid:学号 Sname:学生姓名Sbirth:学生生日Ssex:学生性别01 赵雷 1990-01-01 男02 钱电 1990-12-21 男03 孙风 1990-05-20 男04 李云 1990-08-06 男05 周梅 1991-12-01 女06 吴兰 1992-03-01 女...原创 2020-02-05 16:49:14 · 1097 阅读 · 0 评论 -
HQL练习_03:用户观看节目
t45t原创 2020-02-02 23:43:29 · 697 阅读 · 2 评论 -
HQL的规范
一、Group by1.1selectuname,floor(age/10) flagfrom programgroup by uname;会报错:FAILED: SemanticException [Error 10025]: Line 2:6 Expression not in GROUP BY key '10'原因:group by 后并没有age解决...原创 2020-02-02 22:40:55 · 736 阅读 · 0 评论 -
HQL中遇到的error_01
一、查询出的字段想要把列名改成中文,select s_id as '用户' from score;报错如下:NoViableAltException(313@[134:7: ( ( ( KW_AS )? identifier ) | ( KW_AS LPAREN identifier ( COMMA identifier )* RPAREN ) )?]) at or...原创 2020-02-02 21:46:37 · 615 阅读 · 0 评论 -
HQL练习_01简单的一些基础练习
换座位小美是一所中学的信息科技老师,她有一张 seat 座位表,平时用来储存学生名字和与他们相对应的座位 id。其中纵列的 id 是连续递增的小美想改变相邻俩学生的座位。你能不能帮她写一个 SQL query 来输出小美想要的结果呢?示例:±--------±--------+| id | student |±--------±--------+| 1 | Abbot || 2...原创 2020-02-01 20:51:27 · 1271 阅读 · 0 评论