hadoop hive
文章平均质量分 57
blackproof
这个作者很懒,什么都没留下…
展开
-
HIVE 第一章 数据类型
hive数据:struct(name:string,age:int)struct('dirk','36'){"street":"1 Michigan Ave.","city":"Chicago","state":"IL","zip":60600} map<String,float>map('dirk','36','原创 2013-02-12 14:22:58 · 64 阅读 · 0 评论 -
HIVE 第六章 视图
create view if not exists shipments(time,part)comment 'time and parts for shipments'tblproperties('creator'='me')as select...; 通过试图建tablecreate table shipments2 like shipments 删除viewdrop view if exists shipments 修改view属性alter view原创 2013-02-13 22:16:53 · 112 阅读 · 0 评论 -
HIVE 第七章 索引
or'='dirk','created_at'='some_time')in table employees_index_tablepartitioned by (country,name)comment 'employees indexed by country and name' 显示表的索引 #formatted是可选show formatted index on employeesshow formatted indexed on employees 删除索引表原创 2013-02-13 22:17:14 · 98 阅读 · 0 评论 -
HIVE 第八章 schema
string,quantity int) partitioned by (int day)alter table supply add partition (day=20120102)partition的负面影响:1.namenode limition但是partition产生的子目录,子文件都会保存在hdfs中,namenode会存在内存中,所以这得负面效果是namenode的filesystem的容量上限(hadoop has this upper limit on the total原创 2013-02-13 22:17:51 · 1410 阅读 · 0 评论 -
hive常用函数
字符串反转函数:reverse 语法: reverse(string A)返回值: string说明:返回字符串A的反转结果举例:hive> select reverse(‘abcedfg’) from dual;gfdecba 字符串连接函数:concat 语法: concat(string A, string B…)返回值: string说明:返回输入字符串连接后的结果,支持任意个输入字符串举例:hive&原创 2014-08-24 21:44:47 · 391 阅读 · 0 评论 -
hive经验
括号3.hive的column别名,不能取已经存在的column 4.if(x=1 and y=2,1,null) if函数条件只能是and or而且不能有嵌套,也就是带括号,所以in条件也不能有要使用CASE WHEN Fruit = 'APPLE' THEN 'The owner is APPLE' WHEN Fruit = 'ORANGE' THEN 'The owner is ORANGE' ELSE 'It is another Fruit'END代替 5.原创 2014-09-05 13:56:28 · 109 阅读 · 0 评论 -
hive查询导出到hdfs,hive,file
elease_date_10' select release_date from item limit 10; insert overwrite table data2 partition(dt='1997-12') select * from data where from_unixtime(timestamp, 'yyyy-MM') = '1997-12'; 导入到hiveload data local inpath '${OUTPUT}/hive_subscribe_biz.*.$原创 2014-10-28 20:22:51 · 271 阅读 · 0 评论 -
hive UDAF
; public class helloUDAF extends UDAF { public static class Evaluator implements UDAFEvaluator { //存放不同学生的总分 private static Map<String,Integer> ret; public Evaluator() { s原创 2014-09-30 14:32:57 · 67 阅读 · 0 评论 -
MapredLocalTask报错
原创 2014-10-28 20:22:05 · 1209 阅读 · 0 评论 -
hive not in
key from a where key not in(select key from b) 可以通过left outer join进行查询,(假设B表中包含另外的一个字段 key1 Sql代码 select a.key from a left outer join b on a.key=b.key where b.key1 is null原创 2014-11-25 18:00:57 · 196 阅读 · 0 评论 -
hive建表
ed by ( logday string ) row format delimited fields terminated by '\t'collection items terminated by ','lines terminated by '\n'stored as textfile location '/xxxxxxxx/xxxx'; CREATE EXTERNAL TABLE page_view( viewTime INT,原创 2014-11-11 15:02:49 · 71 阅读 · 0 评论 -
hive join
原创 2014-11-13 16:49:12 · 68 阅读 · 0 评论 -
hive与hbase安装
erby是一个Open source的产品,基于Apache License 2.0分发•即将元数据存储在Derby数据库中,也是Hive默认的安装方式 安装Hive•解压Hive[java] view plaincopy tar zxvf hive-0.8.1.tar /home/test/Desktop •建立软连接[java] view plaincopy ln –s hive-0.8.1原创 2014-11-20 16:32:41 · 82 阅读 · 0 评论 -
hive函数
/Hive/LanguageManual+UDF 1.内置运算符 1.1关系运算符 运算符类型说明A = B所有原始类型如果A与B相等,返回TRUE,否则返回FALSEA == B无失败,因为无效的语法。 SQL使用”=”,不使用”==”。A <> B所有原始类型如果A不等于B返回TRUE,否则返回FALSE。如果A或B值为”NULL”,结果返回”NULL”。A <原创 2014-12-08 13:25:55 · 90 阅读 · 0 评论 -
hive row_number分组排序top
v前十的用户select*,row_number() OVER(PARTITION BY t3.action ORDER BY pv desc) AS flagfrom(select action,uuid,count(1) as pvfrom logtable tgroup by t.action,uuid) t1where t1.flag<=10 贴一个oracle rank的帖子rank,dense原创 2014-12-08 17:59:14 · 287 阅读 · 0 评论 -
hive报错 Exception thrown obtaining schema column information from datastore
astore at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.refreshTableData(RDBMSSchemaHandler.java:986) at org.datanucleus.store.rdbms.schema.RDBMSSchemaHandler.getRDBMSTableInfoForTable(RDBMSSchemaHandler.java:821) at org.datanucleus.store.rdb原创 2015-03-11 14:53:38 · 1153 阅读 · 0 评论 -
hive压缩
ion items terminated by ','lines terminated by '\n'STORED AS INPUTFORMAT 'com.hadoop.mapred.DeprecatedLzoTextInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'location '/user/hive/warehouse/xxx'; hive查询输出压缩原创 2015-03-19 18:45:26 · 89 阅读 · 0 评论 -
hive修改inputformat
TINPUTFORMAT “com.hadoop.mapred.DeprecatedLzoTextInputFormat”OUTPUTFORMAT “org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat”;ALTER TABLE foo PARTITION (pt=’2013-06-04′) SET FILEFORMATINPUTFORMAT “com.hadoop.mapred.DeprecatedLzoTextInputFormat”O原创 2015-03-27 10:38:22 · 2419 阅读 · 0 评论 -
HIVE 第五章 查询
ECT upper(name), salary, deductions["Federal Taxes"],round(salary * (1 - deductions["Federal Taxes"])) FROM employees; 3.expressionSELECT count(*), avg(salary) FROM employees; 4.distinctSELECT count(DISTINCT symbol) FROM s原创 2013-02-13 22:16:17 · 103 阅读 · 0 评论 -
HIVE 第四章 数据操作
原创 2013-02-12 14:27:57 · 83 阅读 · 0 评论 -
HIVE 第二章 目录和表
1.目录篇创建表目录create database companyscreate database companys location tablecreate database companys location table with dbproperties('name'='kedde','data'='2012-01-02')查看database信息,无法查看当前表目录...原创 2013-02-12 14:24:42 · 80 阅读 · 0 评论 -
HIVE 第四章 数据操作
数据操作篇加载数据(会生成partition,如果不存在的话;local字段表示为是本机目录,如果不加,则表示为hdfs上的目录;overwrite关键字表示删除目标目录,当没有则保留,但会覆盖同名旧目录)一些限制条件:使用partition,则table必须是partition的;hive不会去验证你的data是服务schema的,但是hive会验证文件是否符合表定义,如sequen...原创 2013-02-12 14:27:57 · 84 阅读 · 0 评论 -
HIVE 第五章 查询
查询语句查询的一些例子:1.queryhive> SELECT name, subordinates[0] FROM employees;John Doe Mary SmithMary Smith Bill KingTodd Jones NULL 2.expressionhive> SELECT upper(name), salary, d...原创 2013-02-13 22:16:17 · 93 阅读 · 0 评论 -
HIVE 第六章 视图
第七章 试图view1create view shorter_join asselect * from people join carton(cart.people_id=people.id) where firstname='dirk' select lastname from shorter_join where id=3 view2create vie...原创 2013-02-13 22:16:53 · 78 阅读 · 0 评论 -
HIVE 第七章 索引
索引创建索引create index employees_indexon table employees(country)as 'bitmap' #使用bitmap函数建立索引with deferred rebuildidxproperties('creator'='dirk','created_at'='some_time')...原创 2013-02-13 22:17:14 · 72 阅读 · 0 评论 -
hive常用函数
字符串函数字符串长度函数:length 语法: length(string A)返回值: int说明:返回字符串A的长度举例:hive> select length(‘abcedfg’) from dual;7 字符串反转函数:reverse 语法: reverse(string A)返回值: string说明:返回字符串...原创 2014-08-24 21:44:47 · 88 阅读 · 0 评论 -
hive查询导出到hdfs,hive,file
INSERT OVERWRITE LOCAL DIRECTORY '/script/dirk.zhang/test' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' select... ...; insert overwrite [local] directory '/data/movielens/100k/output/item_rel...原创 2014-10-28 20:22:51 · 149 阅读 · 0 评论 -
hive建表
hive分内部表和外部表 create table xxx( logtime string , traceid string , param string , result string , runtime string ) partitioned by ( l...原创 2014-11-11 15:02:49 · 75 阅读 · 0 评论 -
hive not in
当前HIVE 不支持 not in 中包含查询子句的语法,形如如下的HQ语句是不被支持的: 查询在key字段在a表中,但不在b表中的数据 Sql代码 select a.key from a where key not in(select key from b) 可以通过left outer join进行查询,(假设B表中包含另外的一个字段 key1 ...原创 2014-11-25 18:00:57 · 79 阅读 · 0 评论 -
hive row_number分组排序top
自从hive 0.11.0 开始,加入了类似orcle的分析函数,很强大,可以查询到分组排序top值使用方法跟oracle没有差别 贴个小例子查询的是同一个操作下pv前十的用户select*,row_number() OVER(PARTITION BY t3.action ORDER BY pv desc) AS flagfrom(select act...原创 2014-12-08 17:59:14 · 120 阅读 · 0 评论 -
HIVE 第一章 数据类型
"Federal Taxes":0.2,"State Taxes":0.05,"Insurance":0.1} array<string>array('dirk','kedde')["Mary Smith","Todd Jones"] null为特殊的数据类型,表示unknown data,可以是数据丢失,数据错误等原创 2013-02-12 14:22:58 · 85 阅读 · 0 评论 -
HIVE 第二章 目录和表
原创 2013-02-12 14:24:42 · 88 阅读 · 0 评论 -
hive sql优化
好), 这是由参数hive.auto.convert.join=true 和hive.smalltable.filesize=25000000L)参数控制(默认是25M),如果表文件大小在25M左右,可以适当调整此参数,进行map side join,避免reduce side join。 也可以显示声明进行map join:特别适用于小表join大表的时候,SELECT /*+ MAPJOIN(b) */ a.key, a.value FROM a join b on a.key = b.key2.原创 2015-11-13 17:47:40 · 174 阅读 · 0 评论