《Programming Hive》读书笔记(二)Hive基础知识
2014-11-15 22:43
417 查看
《Programming Hive》读书笔记(二)Hive基础知识
阅读方法:第一遍读是浏览,建立知识索引,因为有些知识不一定能用到,知道就好。感兴趣的部分可以多研究。
以后用的时候再详细看,并结合其他资料一起。
Chapter 3.Data Types and File Formats
原始数据类型和集合数据类型
Select出来的数据,列与列之间的分隔符可以指定
Chapter 4.HiveQL:Data Definition
创建数据库,创建和改动表,分区的操作
Chapter 5.HiveQL:Data Manipulation
1 加载数据和导出数据,应该从本地和HDFS都可以。
2 创建表和将查询结果插入到表中
Chapter 6.HiveQL:Queries select的各种语法,join,cluster by等
Where支持正则表达式like,rlike
JOIN:On条件不支持不等号,不支持OR
1 先join再where,会根据join过滤一批数据,然后根据where过滤一批
2 The partition filters are ignored for OUTER JOINTS. However, usingsuch filter predicates in ON clauses for inner joins does work!
在outer join中,在on里面写分区条件是没用的。如果想通过分区条件加快速度,可以通过子查询再join的方法。
Inner join,left outer join,right outerjoin,left semi join(in的作用,但貌似高版本的hive支持in子查询)
hive >SELECT
*FROM
stocksJOIN
dividends
> WHEREstock.symbol=
dividends.symboland
stock.symbol='AAPL';
Hive里面,这条sql会先算笛卡尔积的再根据where过滤。
In Hive,this query computes the full Cartesianproduct before applying the WHERE
clause. Itcould take a very long time to finish. When the property hive.mapred.modeis
set to strict, Hive prevents users from inadvertentlyissuing a Cartesian product query.
两个表join,如果其中一个较小,可以通过map-side-join的方法加快速度。
不过这种优化不支持right-join和full-join。
Hive does not support theoptimization for right- and full-outer joins.
优化:满足一定条件,设置对应的参数开启。
The ORDER BY clause is familiar from other SQL dialects. It performs atotal orderingof
the query result set.This means that all the data is passed through a single reducer,
which may take an unacceptablylong time to execute for larger data sets.
Order by的排序是全局的,最后全部数据通过一个reducer来排序。
Because ORDER BY can result in excessively long run times, Hive willrequire a LIMIT
clause with ORDER BY if the property hive.mapred.mode is set to strict. Bydefault, it is
set to nonstrict.(注意事项)
sort by的排序是局部的
DISTRIBUTEBY controls how map output isdivided among reducers.
DISTRIBUTEBY可以指定map输出之后如何分配到各个reducer中。
通常是某个字段相同放在同一个reducer中,有点像groupby的思想。
经常跟sort by一起用(DISTRIBUTEBY放前面),达到先分组再内部排序的效果。
Cluster by相等于distribute by加上sort by的效果。
额外资料:
http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2843243.html
cast(valueAS TYPE)
强制性转换时,得注意转换后的值,看看是否达到你所需要的效果。
Queries from sample data
随机抽取数据
部分未不懂,先不管。
BlockSampling
Input Pruningfor Bucket Tables
Union all合并两个表
本文作者:linger
本文链接:http://blog.csdn.net/lingerlanlan/article/details/41153799
阅读方法:第一遍读是浏览,建立知识索引,因为有些知识不一定能用到,知道就好。感兴趣的部分可以多研究。
以后用的时候再详细看,并结合其他资料一起。
Chapter 3.Data Types and File Formats
原始数据类型和集合数据类型
Select出来的数据,列与列之间的分隔符可以指定
Chapter 4.HiveQL:Data Definition
创建数据库,创建和改动表,分区的操作
Chapter 5.HiveQL:Data Manipulation
1 加载数据和导出数据,应该从本地和HDFS都可以。
2 创建表和将查询结果插入到表中
Chapter 6.HiveQL:Queries select的各种语法,join,cluster by等
Where支持正则表达式like,rlike
JOIN:On条件不支持不等号,不支持OR
1 先join再where,会根据join过滤一批数据,然后根据where过滤一批
2 The partition filters are ignored for OUTER JOINTS. However, usingsuch filter predicates in ON clauses for inner joins does work!
在outer join中,在on里面写分区条件是没用的。如果想通过分区条件加快速度,可以通过子查询再join的方法。
Inner join,left outer join,right outerjoin,left semi join(in的作用,但貌似高版本的hive支持in子查询)
hive >SELECT
*FROM
stocksJOIN
dividends
> WHEREstock.symbol=
dividends.symboland
stock.symbol='AAPL';
Hive里面,这条sql会先算笛卡尔积的再根据where过滤。
In Hive,this query computes the full Cartesianproduct before applying the WHERE
clause. Itcould take a very long time to finish. When the property hive.mapred.modeis
set to strict, Hive prevents users from inadvertentlyissuing a Cartesian product query.
两个表join,如果其中一个较小,可以通过map-side-join的方法加快速度。
不过这种优化不支持right-join和full-join。
Hive does not support theoptimization for right- and full-outer joins.
优化:满足一定条件,设置对应的参数开启。
The ORDER BY clause is familiar from other SQL dialects. It performs atotal orderingof
the query result set.This means that all the data is passed through a single reducer,
which may take an unacceptablylong time to execute for larger data sets.
Order by的排序是全局的,最后全部数据通过一个reducer来排序。
Because ORDER BY can result in excessively long run times, Hive willrequire a LIMIT
clause with ORDER BY if the property hive.mapred.mode is set to strict. Bydefault, it is
set to nonstrict.(注意事项)
sort by的排序是局部的
DISTRIBUTEBY controls how map output isdivided among reducers.
DISTRIBUTEBY可以指定map输出之后如何分配到各个reducer中。
通常是某个字段相同放在同一个reducer中,有点像groupby的思想。
经常跟sort by一起用(DISTRIBUTEBY放前面),达到先分组再内部排序的效果。
Cluster by相等于distribute by加上sort by的效果。
额外资料:
http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2843243.html
cast(valueAS TYPE)
强制性转换时,得注意转换后的值,看看是否达到你所需要的效果。
Queries from sample data
随机抽取数据
部分未不懂,先不管。
BlockSampling
Input Pruningfor Bucket Tables
Union all合并两个表
本文作者:linger
本文链接:http://blog.csdn.net/lingerlanlan/article/details/41153799
相关文章推荐
- 《Programming Hive》读书笔记(两)Hive基础知识
- 《程序员的自我修养-链接加载与库》读书笔记(1)---基础知识储备
- c/c++基础知识读书笔记二 格式化输入输出
- 《php开发典型模块大全》读书笔记 第二章 基础知识 (张迅雷闪击PHP系列)
- UNIX基础知识--<<UNIX 环境编程>>读书笔记
- UNIX基础知识--<<UNIX 环境编程>>读书笔记
- 《C++捷径教程》读书笔记--Chapter 7--函数,第一部分:基础知识(第一部分)
- 惯性技术基础知识 --《惯性技术(国防工业大学出版社)》读书笔记(1)
- CLR via C# 线程基础知识读书笔记
- 复习C++基础知识-----“我的第一本C++”读书笔记4(终篇)
- 读书笔记——Windows环境下32位汇编语言程序设计(3)一些基础知识
- 读书笔记——《UNIX环境高级编程》第一章_UNIX基础知识
- [读书笔记]C++基础知识温习:智能指针
- [读书笔记]C++基础知识温习:重载递增/减运算符
- 《加密与解密(第三版)》读书笔记第1章(基础知识)
- c/c++基础知识读书笔记四 初级指针
- 复习C++基础知识-----“我的第一本C++”读书笔记2
- [读书笔记]C++基础知识温习:预处理指令
- 《Python基础教程》读书笔记(第一章:基础知识)
- Real World Haskell 读书笔记(1)基础知识