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. Django模型层(2)

    https://www.cnblogs.com/yuanchenqi/articles/8963244.html from django.db import models class Author(m ...

  2. Linux服务器部署系列之一—Apache篇(上)

    Linux系统的应用越来越广泛了,学习linux系统的网管兄弟也有增加的趋势.很久以前就有些想法,要将自己学的linux知识整理一下.最近,终于下定决心,挤出时间开始动手写些东西了.虽然不一定好,不过 ...

  3. IntelliJ IDEA 2017版 SpringBoot的关闭自动配置和自定义Banner

    一.关闭自动配置 在jar包下找下边的名字    设置关闭自动配置jar    多个的时候配置       二.自定义Banner   (1)网站搜索一个图案.网址:http://patorjk.co ...

  4. Redis java client ==> Jedis

    https://github.com/xetorthio/jedis Jedis is a blazingly small and sane Redis java client. Jedis was ...

  5. 使用LVM对系统盘进行扩容

        不知道大家有没有碰到在安装CentOS时个,对系统每个挂载点分配多大容量比较合适的问题?如果挂载点容量分配大小,在某天不够用的时候怎么办:分配太大又存在浪费的情况.特别是在遇到系统盘特别小的时 ...

  6. Android-XML格式描述

    XML是W3C公司提出的标准,使用范围非常广阔,在框架的配置,程序的配置,布局文件的定义,网络传输等,无所不在: 以前学Java的时候,对XML的名词定义是,根节点,子节点 等等,而在Android里 ...

  7. 移动端Retina屏边框线1px 显示为2px或3px问题解决方法

    我们在开发移动端web项目时经常遇到设置border:1px,但是显示的边框却为2px或是3px粗细,这是因为设备像素比devicePixelRatio为2或3引起的.   1.何为“设备像素比dev ...

  8. 设计模式之代理模式(Proxy Pattern)_补充篇

    写在前面: 代理模式的内部原理,作用及远程代理的实现在上一篇博文中都做了详细解释,本文只是对其内容的补充,介绍其它代理 一.虚拟代理 首先,明确虚拟代理的作用:在巨大对象被真正创建出来之前,用虚拟代理 ...

  9. [JS] 数据双向绑定原理

    通常在前端开发过程中,经常遇到需要绑定两个甚至多个元素之间的值,比如将input的值绑定到一个h1上,改变input的值,h1的文字也自动更新. <h1 id="title" ...

  10. vs web项目远程发布到IIS

    一.下载安装 IIS安装管理服务,这里不赘述,安装完后显示如下(装完刷新一下或者重新打开iis) 下载webploy,安装的时候要选中远程功能,或者选择完全安装,否则会因为没有远程模块导致连接失败(注 ...