咱们的hive版本升迁经历了0.7.1 -> 0.8.1 -> 0.9.0,而且线上shark所依赖的hive版本也停留在0.9.0上,在这些版本上有咱们本身的bug fix patch和feature enhancement。可是Hive的版本升级很快,新版本中修复了大量bug,新增了不少功能,很是使人兴奋,其中包括对将来hadoop升级为YARN的支持。因此咱们准备将hive版本升级为0.11(最近看到mailist上0.12版本也快呼之欲出了,可是保险起见,仍是先升级为0.11), 另外shark的github上也已经拉出了hive 0.11分支来支持新版本。html
由于是从0.9一下跳过0.10跨越到0.11,因此调研和测试会cover掉hive 0.10和0.11前端
从hive的release note上,0.10新加的feature和bug fix以下:
1. 支持Cube, Grouping and Rollup语法,能够进行多级group by
https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation,+Cube,+Grouping+and+Rollupgit
2. 对于简单的不须要聚合的相似SELECT <col> from <table> LIMIT 20语句,不须要起MapReduce job,直接经过Fetch task获取数据
https://issues.apache.org/jira/browse/HIVE-887github
3. 新增"Explain dependency"语法,以json格式输出执行语句会读取的input table和input partition信息,这样debug语句会读取那些表就很方便了
https://issues.apache.org/jira/browse/HIVE-3610web
hive (default)> explain dependency select count(1) from abc; OK Explain {"input_partitions":[],"input_tables":[{"tablename":"default@abc","tabletype":"MANAGED_TABLE"}]} Time taken: 0.095 seconds, Fetched: 1 row(s)
4. 新增"show create table"语法,这样能知道是如何建立表的。以前咱们很暴力,直接读取metastore dababase信息来重建表结构信息,若是一旦metastore schema升级,就很容易出问题,此次hive应该是经过metastore client api实现了这个功能,很是靠谱。apache
https://issues.apache.org/jira/browse/HIVE-967json
5. HWI用bootstrap前端框架重写了一边,这个对咱们帮助不大,由于咱们已经有Hive web了bootstrap
6. Hadoop 2 - YARN的兼容性支持api
7. List Bucketing Table,优化处理有数据倾斜的表
https://cwiki.apache.org/confluence/display/Hive/ListBucketing前端框架
8. Union优化,若是Union语句的parent是mapreduce job,那么它会先将结果写入临时文件中,Union再读取这些临时文件写入最终目录,上层语句再读取最终目录,这样致使结果文件读了两遍。优化策略就是结果数据直接往最终目录上写
https://cwiki.apache.org/confluence/display/Hive/Union+Optimization
9. skew join 优化
https://cwiki.apache.org/confluence/display/Hive/Skewed+Join+Optimization
10. metastore支持在server side作authorization验证
https://issues.apache.org/jira/browse/HIVE-3705
11. metastore thrift reconnect支持,当metastore client连接一台metastore thrift server抛出异常,若是用户在conf之指定了多个metastore uris,hive会从新对另一个创建连接,这个对用户端是透明的
https://issues.apache.org/jira/browse/HIVE-3400
12. 记录column统计信息, analyze语句会统计hive table partitions column信息到metastore里面(好比记录long类型column的low value, high value, num nulls, numDVs),同时提供了metastore api接口来访问这些信息,目前的hive优化策略都是基于rule-based的,而有了这些统计信息有助于将来创建cost-based 执行计划策略
语法以下:
analyze table t [partition p] compute statistics for [columns c,...];
https://cwiki.apache.org/confluence/display/Hive/Column+Statistics+in+Hive
13. 支持cross join语法
https://issues.apache.org/jira/browse/HIVE-2549
14. 支持SHOW TBLPROPERTIES语法
https://issues.apache.org/jira/browse/HIVE-2530
----------------------------------------------------不是那么华丽的分割线--------------------------------------------------
Hortonworks发布了一个叫stinger的项目计划,分阶段逐步改善Hive的性能,包括优化器的改进,ORCFile支持,基于DAG的Tez,向量执行引擎,0.11其实就是stinger phase one的产物
0.11 新增的Feature:
1. 把Hcatalog整合到hive里面了,而不是独立的项目
2. 支持ORCFile文件格式,基于列存储,文件内置有inline index,能够基于文件作predicate pushdown,根据stripe的元数据来选择是否跳过stripe,大大下降input size
https://cwiki.apache.org/Hive/languagemanual-orc.html
3. 支持windowing和analytics方法,好比lead/lag, row_number, rank, first, last函数
https://cwiki.apache.org/Hive/languagemanual-windowingandanalytics.html
4. Join优化,包括broadcast join和SMB join,对于在多个相同列上作join的表(star join)已经不依赖于用户指定的hint token了,能够自动转化多个MapReduce job为一个MapReduce job
https://issues.apache.org/jira/browse/HIVE-3403
5. unset TBLPROPERTY
ALTER TABLE tableName UNSET TBLPROPERTIES IF EXISTS (key1, key2, ...)
6. group by 语法加强,group by除了能够跟column alias,也能够跟column position
好比:select f1(col1), f2(col2), f3(col3), count(1) group by f1(col1), f2(col2), f3(col3);能够写成select f1(col1), f2(col2), f3(col3), count(1) group by 1, 2, 3;
https://issues.apache.org/jira/browse/HIVE-581
7. 增长decimal data格式
https://issues.apache.org/jira/browse/HIVE-2693
8. 支持truncate语法,truncate会删除表和分区下的全部数据,可是metadata信息会保留
9. 新增Hive Server 2,解决以前存在的security和concurrency问题。同时新增长了Beeline CLI(基于SQLLine),能够在command-line中以交互式的访问Hive Server 2
https://issues.apache.org/jira/browse/HIVE-2935
10. 加强Query Plan优化策略,会删除冗余的operator
https://issues.apache.org/jira/browse/HIVE-948
接下来会重点对几个新增特性,好比Hive Server 2, ORCFile, SMB join等作更深刻的调研和测试
本文连接http://blog.csdn.net/lalaguozhe/article/details/11730817,转载请注明