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表)的更多相关文章

  1. yii 多表联合查询的几种方法

    yii多表联合查询, 第一种,用command,自己拼接sql语句执行查询 第二种,用AR,model需继承下面的ar,执行queryall或queryrow方法 <?php //applica ...

  2. MVC5+EF6简单实例---以原有SQLServer数据库两表联合查询为例

    有二三年没写代码了,**内的工作就是这样,容易废人!看到园子里这么多大侠朝气蓬勃的,我想也要学点东西并和大家分享,共同进步!快乐每一天,进步每一天!言归正传! 通过最近一段时间对MVC5.EF6的学习 ...

  3. Dynamic CRM 2013学习笔记(九)CrmFetchKit.js介绍:Fetchxml、多表联合查询, 批量更新

    CrmFetchKit.js是一个跨浏览器的一个类库,允许通过JavaScript来执行fetch xml的查询,还可以实现批量更新,分页查询等.目前已支持Chrome 25, Firefox 19 ...

  4. SharePoint 2013 列表多表联合查询

    在SharePoint的企业应用中,遇到复杂的逻辑的时候,我们会需要多表查询:SharePoint和Sql数据表一样,也支持多表联合查询,但是不像Sql语句那样简单,需要使用SPQuery的Joins ...

  5. MyBatis 多表联合查询及优化 以及自定义返回结果集

    下面就来说一下 mybatis 是通过什么来实现多表联合查询的.首先看一下表关系,如图: 这 里,我已经搭好了开发的环境,用到的是 SpringMVC + Spring + MyBatis,当然,为了 ...

  6. 一步步学Mybatis-实现多表联合查询(4)

    上一章节中我们已经完成了对单表的CRUD操作,接下来今天这一讲讲述的是关于Mybatis在多表查询时候的应用,毕竟实际业务中也是多表的联合查询比较多嘛~ 还记得最一开始我们新建过一张Website表吗 ...

  7. MyBatis之三:多表联合查询

    在这篇文章里面主要讲解如何在mybatis里面使用一对一.一对多.多表联合查询(类似视图)操作的例子. 注:阅读本文前请先大概看一下之前两篇文章. 一.表结构 班级表class,学生表student, ...

  8. MyBatis 多表联合查询,字段重复的解决方法

    MyBatis 多表联合查询,两张表中字段重复时,在配置文件中,sql语句联合查询时使用字段别名,resultMap中对应的column属性使用相应的别名: <resultMap type=&q ...

  9. ormlite 多表联合查询

    ormlite 多表联合查询 QueryBuilder shopBrandQueryBuilder = shopBrandDao.queryBuilder(); QueryBuilder shopQu ...

  10. Mybatis oracle多表联合查询分页数据重复的问题

    Mybatis oracle多表联合查询分页数据重复的问题 多表联合查询分页获取数据时出现一个诡异的现象:数据总条数正确,但有些记录多了,有些记录却又少了甚至没了.针对这个问题找了好久,最后发现是由于 ...

随机推荐

  1. Spring Cloud基础教程视频教程

    视频课程包含: Spring Cloud基础视频教程24G 目录 获取方式: 关注公众微信号:博涵大数据 或者扫描下面的二维码关注获取. 关注后在公众平台上回复"SpringCloud基础& ...

  2. sql左外连接、右外连接、group by、distinct(区别)、intersect(交叉)、通配符、having

    连接条件可在FROM或WHERE子句中指定,建议在FROM子句中指定连接条件.WHERE和HAVING子句也可以包含搜索条件,以进一步筛选连接条件所选的行.             连接可分为以下几类 ...

  3. DEVEXPRESS 破解方法

    Devexpress 是.net的一个非常好用的插件.能够轻松的帮你实现一个非常炫的UI,无论是C#的Winform还是ASP.NET的网站. 鄙人这两天在用DEVEXPRESS的过程中发现在网上并未 ...

  4. passwd: Have exhausted maximum number of retries for service

    使用命令passwd修改密码时,遇到如下问题:# echo 'utf8'|passwd zhangsan --stdinChanging password for user zhangsan.pass ...

  5. Codeforces758A Holiday Of Equality 2017-01-20 10:08 48人阅读 评论(0) 收藏

    A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. 快速学会在JSP中使用EL表达式

    在没有学会EL表达式之前,我们想在JSP文件中获取servlet或者其他JSP页面传来的值,通常都是在JSP页面中编写java代码来实现.而在jsp页面编写Java 代码,这种做法时不规范的,将会产生 ...

  7. 解决Sublime Text 3中文显示乱码和语法着色问题 等问题

    一:解决sublime中文乱码的问题 简单安装: 1.打开Sublime Text 3,按Ctrl+-打开控制行,复制粘贴以下python代码,然后回车运行. 2. 复制并粘贴如下代码: import ...

  8. Android-上下文菜单Menu

    上一篇博客介绍了,Android-普通菜单Menu,而这篇博客介绍Android-上下文菜单Menu AndroidManifest.xml 中加入权限: <!-- 读取联系人数据的权限 --& ...

  9. 设计模式之状态模式(State Pattern)

    一.什么是状态模式? 把所有动作都封装在状态对象中,状态持有者将行为委托给当前状态对象 也就是说,状态持有者(比如汽车,电视,ATM机都有多个状态)并不知道动作细节,状态持有者只关心自己当前所处的状态 ...

  10. 在Docker中运行纸壳CMS并配置使用MySql

    纸壳CMS是基于ASP.Net Core开发的可视化内容管理系统,可以跨平台部署,可以在容器中运行.接下来看看如何在docker中运行纸壳CMS. GitHub:https://github.com/ ...