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. 2018.08.28 洛谷P4556 [Vani有约会]雨天的尾巴(树上差分+线段树合并)

    传送门 要求维护每个点上出现次数最多的颜色. 对于每次修改,我们用树上差分的思想,然后线段树合并统计答案就行了. 注意颜色很大需要离散化. 代码: #include<bits/stdc++.h& ...

  2. csdn的一次回答问题

    #coding:utf8 import tushare as ts import pandas as pd import numpy as np import pymysql,datetime imp ...

  3. CreateDialog()与CreateDialogIndrect()

    CreateDialog() 概述 函数功能:CreateDialog宏从一个对话框模板资源创建一个无模式的对话框,CreateDiaog宏使用CreateDialogParam函数. 函数原型:HW ...

  4. _variant_t与其他数据类型的转换

    转自:http://kuaixingdong.blog.hexun.com/29627840_d.html 我们先看看COM所支持的一些类型的基本类: (微软提供,在comdef.h中定义) 在COM ...

  5. 系统目录APK更新——权限问题

    package com.example.wx; import java.io.File;import java.io.FileOutputStream;import java.io.IOExcepti ...

  6. 洛谷P1600 天天爱跑步(线段树合并)

    小c同学认为跑步非常有趣,于是决定制作一款叫做<天天爱跑步>的游戏.<天天爱跑步>是一个养成类游戏,需要玩家每天按时上线,完成打卡任务. 这个游戏的地图可以看作一一棵包含 nn ...

  7. 老码农冒死揭开行业黑幕:如何编写无法维护的代码[ZZ]

    下面是一篇有意思的"代码大全",可谓 逆软件工程. 老码农冒死揭开行业黑幕:如何编写无法维护的代码 原文如下 让自己稳拿铁饭碗 ;-) – Roedy Green(翻译版略有删节) ...

  8. [C#]C#时间日期操作

    一.C# 日期格式 1. DateTime dt = DateTime.Now; 2. dt.ToString();//2005-11-5 13:21:25 3. dt.ToFileTime().To ...

  9. 什么是fortran语言之fortran语言入门

    Fortran源自于“公式翻译”(英语:FormulaTranslation)的缩写,是一种编程语言.它是世界上最早出现的计算机高级程序设计语言,广泛应用于科学和工程计算领域.FORTRAN语言以其特 ...

  10. mvc 读写txt文档

    -----------------写入内容---------------- string userfile = "UserData.txt"; StreamWriter sw = ...