hive多表联合查询(GroupLens->Users,Movies,Ratings表)
hive (UserMovieRating)> create table if not exists Users(
> UserID int comment 'user id',
> Gender string comment 'user sex',
> Age int comment '1:Under 18,18:18-24,25:25-34,35:35-44,45:45-49,50:50-55,56:56+',
> Occupation int comment '0-20 represents different jobs',
> ZipCode string comment 'your home zip code')
> row format delimited fields terminated by '\t'
> stored as textfile;
OK
Time taken: 0.249 seconds
hive (UserMovieRating)> load data local inpath '/home/landen/MahoutTest/users.txt' overwrite into table Users;
Copying data from file:/home/landen/MahoutTest/users.txt
Copying file: file:/home/landen/MahoutTest/users.txt
Loading data to table usermovierating.users
Deleted hdfs://Master:9000/home/landen/UntarFile/hive-0.10.0/warehouse/usermovierating.db/users
Table usermovierating.users stats: [num_partitions: 0, num_files: 1, num_rows: 0, total_size: 110208, raw_data_size: 0]
OK
Time taken: 0.745 seconds
hive (UserMovieRating)> select * from Users limit 10;
OK
userid gender age occupation zipcode
1 F 1 10 48067
2 M 56 16 70072
3 M 25 15 55117
4 M 45 7 02460
5 M 25 20 55455
6 F 50 9 55117
7 M 35 1 06810
8 M 25 12 11413
9 M 25 17 61614
10 F 35 1 95370
Time taken: 0.096 seconds
hive (UserMovieRating)> create table if not exists Movies(
> MovieID int comment 'movie id',
> MovieName string comment 'movie name',
> ReleasedDate int comment 'released year',
> MovieType string comment 'movie type')
> row format delimited fields terminated by '\t'
> stored as textfile;
OK
Time taken: 0.183 seconds
hive (UserMovieRating)> show tables;
OK
tab_name
movies
users
Time taken: 0.083 seconds
hive (UserMovieRating)> load data local inpath '/home/landen/MahoutTest/Processedmovies.txt' overwrite into table Movies;
Copying data from file:/home/landen/MahoutTest/Processedmovies.txt
Copying file: file:/home/landen/MahoutTest/Processedmovies.txt
Loading data to table usermovierating.movies
Deleted hdfs://Master:9000/home/landen/UntarFile/hive-0.10.0/warehouse/usermovierating.db/movies
Table usermovierating.movies stats: [num_partitions: 0, num_files: 1, num_rows: 0, total_size: 155900, raw_data_size: 0]
OK
Time taken: 0.695 seconds
hive (UserMovieRating)> select * from Movies limit 10;
OK
movieid moviename releaseddate movietype
1 Toy Story 1995 Animation,Children's,Comedy
2 Jumanji 1995 Adventure,Children's,Fantasy
3 Grumpier Old Men 1995 Comedy,Romance
4 Waiting to Exhale 1995 Comedy,Drama
5 Father of the Bride Part II 1995 Comedy
6 Heat 1995 Action,Crime,Thriller
7 Sabrina 1995 Comedy,Romance
8 Tom and Huck 1995 Adventure,Children's
9 Sudden Death 1995 Action
10 GoldenEye 1995 Action,Adventure,Thriller
Time taken: 0.095 seconds
hive (UserMovieRating)> create table if not exists Rating(
> UserID int comment 'user id',
> MovieID int comment 'movie id(1-3952)',
> Rating int comment 'Ratings are made on a 5-star scale',
> RatingTime string comment 'user rates time')
> row format delimited fields terminated by '\t'
> stored as textfile;
OK
Time taken: 1.3 seconds
hive (UserMovieRating)> load data local inpath '/home/landen/MahoutTest/ProcessedRating.txt' overwrite into table Rating;
Copying data from file:/home/landen/MahoutTest/ProcessedRating.txt
Copying file: file:/home/landen/MahoutTest/ProcessedRating.txt
Loading data to table usermovierating.rating
Deleted hdfs://Master:9000/home/landen/UntarFile/hive-0.10.0/warehouse/usermovierating.db/rating
Table usermovierating.rating stats: [num_partitions: 0, num_files: 1, num_rows: 0, total_size: 21593504, raw_data_size: 0]
OK
Time taken: 3.293 seconds
hive (UserMovieRating)> select * from Rating limit 10;
OK
userid movieid rating ratingtime
1 1193 5 978300760
1 661 3 978302109
1 914 3 978301968
1 3408 4 978300275
1 2355 5 978824291
1 1197 3 978302268
1 1287 5 978302039
1 2804 5 978300719
1 594 4 978302268
1 919 4 978301368
Time taken: 0.658 seconds
hive (UserMovieRating)> describe users;
OK
col_name data_type comment
userid int user id
gender string user sex
age int 1:Under 18,18:18-24,25:25-34,35:35-44,45:45-49,50:50-55,56:56+
occupation int 0-20 represents different jobs
zipcode string your home zip code
Time taken: 0.514 seconds
hive (UserMovieRating)> describe movies;
OK
col_name data_type comment
movieid int movie id
moviename string movie name
releaseddate int released year
movietype string movie type
Time taken: 0.085 seconds
hive (UserMovieRating)> describe ratings;
FAILED: SemanticException [Error 10001]: Table not found ratings
hive (UserMovieRating)> describe rating;
OK
col_name data_type comment
userid int user id
movieid int movie id(1-3952)
rating int Ratings are made on a 5-star scale
ratingtime string user rates time
Time taken: 0.121 seconds
Users,Movies,Rating三表联合查询:
hive (UserMovieRating)> select u.userid,u.occupation,m.moviename,r.rating
> from rating r
> join users u on r.userid = u.userid
> join movies m on r.movieid = m.movieid;
hive多表联合查询(GroupLens->Users,Movies,Ratings表)的更多相关文章
- yii 多表联合查询的几种方法
yii多表联合查询, 第一种,用command,自己拼接sql语句执行查询 第二种,用AR,model需继承下面的ar,执行queryall或queryrow方法 <?php //applica ...
- MVC5+EF6简单实例---以原有SQLServer数据库两表联合查询为例
有二三年没写代码了,**内的工作就是这样,容易废人!看到园子里这么多大侠朝气蓬勃的,我想也要学点东西并和大家分享,共同进步!快乐每一天,进步每一天!言归正传! 通过最近一段时间对MVC5.EF6的学习 ...
- Dynamic CRM 2013学习笔记(九)CrmFetchKit.js介绍:Fetchxml、多表联合查询, 批量更新
CrmFetchKit.js是一个跨浏览器的一个类库,允许通过JavaScript来执行fetch xml的查询,还可以实现批量更新,分页查询等.目前已支持Chrome 25, Firefox 19 ...
- SharePoint 2013 列表多表联合查询
在SharePoint的企业应用中,遇到复杂的逻辑的时候,我们会需要多表查询:SharePoint和Sql数据表一样,也支持多表联合查询,但是不像Sql语句那样简单,需要使用SPQuery的Joins ...
- MyBatis 多表联合查询及优化 以及自定义返回结果集
下面就来说一下 mybatis 是通过什么来实现多表联合查询的.首先看一下表关系,如图: 这 里,我已经搭好了开发的环境,用到的是 SpringMVC + Spring + MyBatis,当然,为了 ...
- 一步步学Mybatis-实现多表联合查询(4)
上一章节中我们已经完成了对单表的CRUD操作,接下来今天这一讲讲述的是关于Mybatis在多表查询时候的应用,毕竟实际业务中也是多表的联合查询比较多嘛~ 还记得最一开始我们新建过一张Website表吗 ...
- MyBatis之三:多表联合查询
在这篇文章里面主要讲解如何在mybatis里面使用一对一.一对多.多表联合查询(类似视图)操作的例子. 注:阅读本文前请先大概看一下之前两篇文章. 一.表结构 班级表class,学生表student, ...
- MyBatis 多表联合查询,字段重复的解决方法
MyBatis 多表联合查询,两张表中字段重复时,在配置文件中,sql语句联合查询时使用字段别名,resultMap中对应的column属性使用相应的别名: <resultMap type=&q ...
- ormlite 多表联合查询
ormlite 多表联合查询 QueryBuilder shopBrandQueryBuilder = shopBrandDao.queryBuilder(); QueryBuilder shopQu ...
- Mybatis oracle多表联合查询分页数据重复的问题
Mybatis oracle多表联合查询分页数据重复的问题 多表联合查询分页获取数据时出现一个诡异的现象:数据总条数正确,但有些记录多了,有些记录却又少了甚至没了.针对这个问题找了好久,最后发现是由于 ...
随机推荐
- htoi的实现
htoi的实现 /************************************************************************* > File Name: h ...
- 教你把p标签的一行字掰弯文字换行): word-wrap: break-word;
1 使用前的p是这样: 2 使用后: p{ word-wrap: break-word; overflow: hidden; } 3 又想变直: p{ word-wrap: normal; ove ...
- php mysql增删查改
php mysql增删查改代码段 $conn=mysql_connect('localhost','root','root'); //连接数据库代码 mysql_query("set na ...
- MySQL外键使用及说明详解
一.外键约束 MySQL通过外键约束来保证表与表之间的数据的完整性和准确性. 外键的使用条件: 1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持 ...
- nginx 配置图片服务器 (window版本)
配置nginx二级域名 ①找到配置文件 例如:%nginx_home%/conf/nginx.conf ②配置 #user nobody; worker_processes 1; #error_log ...
- PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏
1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
- 用 PHP 编写 http 服务器
概述 众所周知,我们一般使用 PHP 开发Web程序时需要使用到比如Apache或Nginx等Web服务器来支持,那么有没有办法直接使用PHP开发HTTP服务器,答案当然是可以的,最近看了一遍Work ...
- hdu 2780 Su-Su-Sudoku(DFS数独)
题目链接:hdu2780 #include<stdio.h> #include<string.h> #include<queue> #include<math ...
- Delphi for iOS开发指南(1):在Mac上配置你的开发环境
http://cache.baiducontent.com/c?m=9d78d513d99516f11ab7cf690d678c3b584380122ba7a0020fd18438e4732b4050 ...
- sun.jersey使用Jackson转换数据
差点被com.sun.jersey自身的json转换吓死,遇到List等类型,会把这些也转换为json对象,而不是jsonarray. 被园里的同行拯救了,在web.xml中配置一下就ok. < ...