- 浏览: 299161 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (165)
- hadoop (47)
- linux (11)
- nutch (7)
- hbase (7)
- solr (4)
- zookeeper (4)
- J2EE (1)
- jquery (3)
- java (17)
- mysql (14)
- perl (2)
- compass (4)
- suse (2)
- memcache (1)
- as (1)
- roller (1)
- web (7)
- MongoDB (8)
- struts2 (3)
- lucene (2)
- 算法 (4)
- 中文分词 (3)
- hive (17)
- noIT (1)
- 中间件 (2)
- maven (2)
- sd (0)
- php (2)
- asdf (0)
- kerberos 安装 (1)
- git (1)
- osgi (1)
- impala (1)
- book (1)
- python 安装 科学计算包 (1)
最新评论
-
dandongsoft:
你写的不好用啊
solr 同义词搜索 -
黎明lm:
meifangzi 写道楼主真厉害 都分析源码了 用了很久. ...
hadoop 源码分析(二) jobClient 通过RPC 代理提交作业到JobTracker -
meifangzi:
楼主真厉害 都分析源码了
hadoop 源码分析(二) jobClient 通过RPC 代理提交作业到JobTracker -
zhdkn:
顶一个,最近也在学习设计模式,发现一个问题,如果老是看别人的博 ...
Java观察者模式(Observer)详解及应用 -
lvwenwen:
木南飘香 写道
高并发网站的架构
Hive的预定义UDF函数列表如下
abs(x) - returns the absolute value of x
acos(x) - returns the arc cosine of x if -1<=x<=1 or NULL otherwise
ascii(str) - returns the numeric value of the first character of str
asin(x) - returns the arc sine of x if -1<=x<=1 or NULL otherwise
bin(n) - returns n in binary
转换成二进制数
ceil(x) - Find the smallest integer not smaller than x
ceiling(x) - Find the smallest integer not smaller than x
coalesce(a1, a2, ...) - Returns the first non-null argument
返回第一个非空的参数
concat(str1, str2) - returns the concatenation of str1 and str2
conv(num, from_base, to_base) - convert num from from_base to to_base
转换进制,从from_base进制转换成to_base
cos(x) - returns the cosine of x (x is in radians)
date_add(start_date, num_days) - Returns the date that is num_days after start_date.
按天做日期加,日期的格式为'yyyy-MM-dd HH:mm:ss'或'yyyy-MM-dd',下同
date_sub(start_date, num_days) - Returns the date that is num_days before start_date.
按天做日期减
datediff(date1, date2) - Returns the number of days between date1 and date2
按天做日期差
day(date) - Returns the date of the month of date
同dayofmonth
dayofmonth(date) - Returns the date of the month of date
elt(n, str1, str2, ...) - returns the n-th string
exp(x) - Returns e to the power of x
floor(x) - Find the largest integer not greater than x
from_unixtime(unix_time, format) - returns unix_time in the specified format
get_json_object(json_txt, path) - Extract a json object from path
解析json object。
path支持JSONPath的一个子集,包括:
* $ : Root object
* . : Child operator
* [] : Subscript operator for array
* * : Wildcard for []
例如,src_json 表只包含一列json,其中的一行内容为:
+-------------------------------------------------------------------+
json
+-------------------------------------------------------------------+
{"store":
{"fruit":[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}],
"bicycle":{"price":19.95,"color":"red"}
},
"email":"amy@only_for_json_udf_test.net",
"owner":"amy"
}
+-------------------------------------------------------------------+
json内容可以用以下查询语句解析
hive> SELECT get_json_object(src_json.json, '$.owner') FROM src_json;
amy
hive> SELECT get_json_object(src_json.json, '$.store.fruit[0]') FROM src_json;
{"weight":8,"type":"apple"}
hive> SELECT get_json_object(src_json.json, '$.non_exist_key') FROM src_json;
NULL
hash(a1, a2, ...) - Returns a hash value of the arguments
hex(n or str) - Convert the argument to hexadecimal
index(a, n) - Returns the n-th element of a
instr(str, substr) - Returns the index of the first occurance of substr in str
isnotnull a - Returns true if a is not NULL and false otherwise
isnull a - Returns true if a is NULL and false otherwise
lcase(str) - Returns str with all characters changed to lowercase
length(str) - Returns the length of str
ln(x) - Returns the natural logarithm of x
locate(substr, str[, pos]) - Returns the position of the first occurance of substr in str after position pos
log([b], x) - Returns the logarithm of x with base b
log10(x) - Returns the logarithm of x with base 10
log2(x) - Returns the logarithm of x with base 2
lower(str) - Returns str with all characters changed to lowercase
lpad(str, len, pad) - Returns str, left-padded with pad to a length of len
ltrim(str) - Removes the leading space characters from str
month(date) - Returns the month of date
negative a - Returns -a
parse_url(url, partToExtract[, key]) - extracts a part from a URL
解析URL字符串,partToExtract的选项包含[HOST,PATH,QUERY,REF,PROTOCOL,FILE,AUTHORITY,USERINFO]。
例如, * parse_url('http://facebook.com/path/p1.php?query=1', 'HOST')返回'facebook.com' * parse_url('http://facebook.com/path/p1.php?query=1', 'PATH')返回'/path/p1.php' * parse_url('http://facebook.com/path/p1.php?query=1', 'QUERY')返回'query=1',可以指定key来返回特定参数,key的格式是QUERY:<KEY_NAME>,例如QUERY:k1 * parse_url('http://facebook.com/path/p1.php?query=1#Ref', 'REF')返回'Ref' * parse_url('http://facebook.com/path/p1.php?query=1#Ref', 'PROTOCOL')返回'http'
a pmod b - Compute the positive modulo
positive a - Returns a
pow(x1, x2) - raise x1 to the power of x2
power(x1, x2) - raise x1 to the power of x2
rand([seed]) - Returns a pseudorandom number between 0 and 1
regexp_extract(str, regexp[, idx]) - extracts a group that matches regexp:例如regexp_extract(url,'.*pvid=(.*?)(&|#|$)',1)!=""其中()的位置即为后面参数1,2,3所获得的数值,当前例子为第一个括号匹配的值
regexp_replace(str, regexp, rep) - replace all substrings of str that match regexp with rep
repeat(str, n) - repeat str n times
reverse(str) - reverse str
round(x[, d]) - round x to d decimal places
rpad(str, len, pad) - Returns str, right-padded with pad to a length of len
rtrim(str) - Removes the trailing space characters from str
sin(x) - returns the sine of x (x is in radians)
size(a) - Returns the size of a
space(n) - returns n spaces
split(str, regex) - Splits str around occurances that match regex ,例如split(split(f.field_ext1, ",")[2],"_")[0],
sqrt(x) - returns the square root of x
substr(str, pos[, len]) - returns the substring of str that starts at pos and is of length len
substring(str, pos[, len]) - returns the substring of str that starts at pos and is of length len
to_date(expr) - Extracts the date part of the date or datetime expression expr
返回date部分的字符串('yyyy-MM-dd')。expr可以是date或datetime('yyyy-MM-dd HH:mm:ss')。
trim(str) - Removes the leading and trailing space characters from str
ucase(str) - Returns str with all characters changed to uppercase
unix_timestamp([date[, pattern]]) - Returns the UNIX timestamp
返回unix风格的time epoch(1970-01-01 00:00:00以来的秒数)。默认返回当前时间的time epoch。
制定date时,返回指定时间的time epoch。可以用pattern制定格式化字符串,用于格式化date。例如 unix_timestamp('20121228', 'yyyyMMdd')返回1356624000
upper(str) - Returns str with all characters changed to uppercase
year(date) - Returns the year of date
abs(x) - returns the absolute value of x
acos(x) - returns the arc cosine of x if -1<=x<=1 or NULL otherwise
ascii(str) - returns the numeric value of the first character of str
asin(x) - returns the arc sine of x if -1<=x<=1 or NULL otherwise
bin(n) - returns n in binary
转换成二进制数
ceil(x) - Find the smallest integer not smaller than x
ceiling(x) - Find the smallest integer not smaller than x
coalesce(a1, a2, ...) - Returns the first non-null argument
返回第一个非空的参数
concat(str1, str2) - returns the concatenation of str1 and str2
conv(num, from_base, to_base) - convert num from from_base to to_base
转换进制,从from_base进制转换成to_base
cos(x) - returns the cosine of x (x is in radians)
date_add(start_date, num_days) - Returns the date that is num_days after start_date.
按天做日期加,日期的格式为'yyyy-MM-dd HH:mm:ss'或'yyyy-MM-dd',下同
date_sub(start_date, num_days) - Returns the date that is num_days before start_date.
按天做日期减
datediff(date1, date2) - Returns the number of days between date1 and date2
按天做日期差
day(date) - Returns the date of the month of date
同dayofmonth
dayofmonth(date) - Returns the date of the month of date
elt(n, str1, str2, ...) - returns the n-th string
exp(x) - Returns e to the power of x
floor(x) - Find the largest integer not greater than x
from_unixtime(unix_time, format) - returns unix_time in the specified format
get_json_object(json_txt, path) - Extract a json object from path
解析json object。
path支持JSONPath的一个子集,包括:
* $ : Root object
* . : Child operator
* [] : Subscript operator for array
* * : Wildcard for []
例如,src_json 表只包含一列json,其中的一行内容为:
+-------------------------------------------------------------------+
json
+-------------------------------------------------------------------+
{"store":
{"fruit":[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}],
"bicycle":{"price":19.95,"color":"red"}
},
"email":"amy@only_for_json_udf_test.net",
"owner":"amy"
}
+-------------------------------------------------------------------+
json内容可以用以下查询语句解析
hive> SELECT get_json_object(src_json.json, '$.owner') FROM src_json;
amy
hive> SELECT get_json_object(src_json.json, '$.store.fruit[0]') FROM src_json;
{"weight":8,"type":"apple"}
hive> SELECT get_json_object(src_json.json, '$.non_exist_key') FROM src_json;
NULL
hash(a1, a2, ...) - Returns a hash value of the arguments
hex(n or str) - Convert the argument to hexadecimal
index(a, n) - Returns the n-th element of a
instr(str, substr) - Returns the index of the first occurance of substr in str
isnotnull a - Returns true if a is not NULL and false otherwise
isnull a - Returns true if a is NULL and false otherwise
lcase(str) - Returns str with all characters changed to lowercase
length(str) - Returns the length of str
ln(x) - Returns the natural logarithm of x
locate(substr, str[, pos]) - Returns the position of the first occurance of substr in str after position pos
log([b], x) - Returns the logarithm of x with base b
log10(x) - Returns the logarithm of x with base 10
log2(x) - Returns the logarithm of x with base 2
lower(str) - Returns str with all characters changed to lowercase
lpad(str, len, pad) - Returns str, left-padded with pad to a length of len
ltrim(str) - Removes the leading space characters from str
month(date) - Returns the month of date
negative a - Returns -a
parse_url(url, partToExtract[, key]) - extracts a part from a URL
解析URL字符串,partToExtract的选项包含[HOST,PATH,QUERY,REF,PROTOCOL,FILE,AUTHORITY,USERINFO]。
例如, * parse_url('http://facebook.com/path/p1.php?query=1', 'HOST')返回'facebook.com' * parse_url('http://facebook.com/path/p1.php?query=1', 'PATH')返回'/path/p1.php' * parse_url('http://facebook.com/path/p1.php?query=1', 'QUERY')返回'query=1',可以指定key来返回特定参数,key的格式是QUERY:<KEY_NAME>,例如QUERY:k1 * parse_url('http://facebook.com/path/p1.php?query=1#Ref', 'REF')返回'Ref' * parse_url('http://facebook.com/path/p1.php?query=1#Ref', 'PROTOCOL')返回'http'
a pmod b - Compute the positive modulo
positive a - Returns a
pow(x1, x2) - raise x1 to the power of x2
power(x1, x2) - raise x1 to the power of x2
rand([seed]) - Returns a pseudorandom number between 0 and 1
regexp_extract(str, regexp[, idx]) - extracts a group that matches regexp:例如regexp_extract(url,'.*pvid=(.*?)(&|#|$)',1)!=""其中()的位置即为后面参数1,2,3所获得的数值,当前例子为第一个括号匹配的值
regexp_replace(str, regexp, rep) - replace all substrings of str that match regexp with rep
repeat(str, n) - repeat str n times
reverse(str) - reverse str
round(x[, d]) - round x to d decimal places
rpad(str, len, pad) - Returns str, right-padded with pad to a length of len
rtrim(str) - Removes the trailing space characters from str
sin(x) - returns the sine of x (x is in radians)
size(a) - Returns the size of a
space(n) - returns n spaces
split(str, regex) - Splits str around occurances that match regex ,例如split(split(f.field_ext1, ",")[2],"_")[0],
sqrt(x) - returns the square root of x
substr(str, pos[, len]) - returns the substring of str that starts at pos and is of length len
substring(str, pos[, len]) - returns the substring of str that starts at pos and is of length len
to_date(expr) - Extracts the date part of the date or datetime expression expr
返回date部分的字符串('yyyy-MM-dd')。expr可以是date或datetime('yyyy-MM-dd HH:mm:ss')。
trim(str) - Removes the leading and trailing space characters from str
ucase(str) - Returns str with all characters changed to uppercase
unix_timestamp([date[, pattern]]) - Returns the UNIX timestamp
返回unix风格的time epoch(1970-01-01 00:00:00以来的秒数)。默认返回当前时间的time epoch。
制定date时,返回指定时间的time epoch。可以用pattern制定格式化字符串,用于格式化date。例如 unix_timestamp('20121228', 'yyyyMMdd')返回1356624000
upper(str) - Returns str with all characters changed to uppercase
year(date) - Returns the year of date
发表评论
-
博客地址变更
2013-08-16 10:29 1158all the guys of visiting the bl ... -
hive 复杂数据结构嵌套
2013-03-14 16:03 5001Hive hive 除了支持基本的数据结构 hive 复 ... -
hive topN 实现
2012-12-14 06:51 1972hive的topN实现 hive的topN实现方式有很多种, ... -
Hive与表操作有关的语句
2012-12-03 14:25 1397Hive与表操作有关的语句 1.创建表的语句: Create ... -
hive参数
2012-11-29 10:18 0第一部分:Hive 参数 hive ... -
hive中的LEFT SEMI JOIN
2012-11-28 14:06 1971hive中的LEFT SEMI JOIN LEFT S ... -
hive Sort By/Order By/Cluster By/Distribute By
2012-10-22 16:51 1064hive Sort By/Order By/Cluster B ... -
hive的权限控制
2012-10-09 17:48 1618hive的权限控制 hiveserver 不支持 并发的访 ... -
hive 基本数据类型
2012-08-30 18:53 0同事整理的,大部分原文摘过来,有少量改动。 1. 基本数据类 ... -
hive cli 操作表分区
2012-08-10 14:04 1220hive表分区 必须在表定义时创建partition a、 ... -
Hive 数据倾斜总结
2012-08-03 14:19 1068Hive 数据倾斜总结 转载:http://www.tbda ... -
hive中 array,map
2012-04-11 23:03 0关于map的操作说明: drop table table2; ... -
hive array数组
2012-04-11 22:58 0hive中的ARRAY类型array是hive中的数组类型 ... -
hive partitions 操作
2012-04-11 11:00 0必须在表定义时创建partition a、单分区建表语句:c ... -
hive 表分区使用
2012-04-09 14:59 0hive表分区 必须在表定义时创建partition ... -
hive执行作业时reduce任务个数设置为多少合适?
2012-04-05 18:05 1329Hive怎样决定reducer个数? Hadoop MapR ... -
JDBC 客户端 连接hive
2012-03-26 16:29 1304Hive的JDBC连接 博客分类: hive JDBCDer ... -
hive 操作语句
2012-02-13 14:13 945https://cwiki.apache.org/conflu ... -
hive+hbase整合
2012-02-03 16:48 6076用hbase做数据库,但由于hbase没有类sql查询方式, ... -
使用MySQL作为Hive的Metastore
2012-02-01 17:56 1976使用MySQL作为Hive的Metastore 前提是成功 ...
相关推荐
hive的udf函数实现
udf函数,用户自定义函数,可以直接在sql语句中计算的函数 优点: 允许实现模块化的程序设计、方便修改代码、增加函数 UDF的执行速度很快,通过缓存计划在语句重复执行时降低代码的编译开销,比存储方法的执行效率...
地址转换成经纬度+两地址间距离计算+省市区位置解析(Java代码) Hive自定义函数的封装
udf开发–做个简单脱敏udf保留前5位,后面全部替换成*****
简单介绍了hive自定义函数的编写步骤以及使用。
* 脱敏UDF函数 * 功能:对一些敏感信息进行脱敏处理,替换方式可选择自定义替换,如'#','*'等,,如不指定脱敏符号,使用个随机字符替换 * 脱敏位置可自定义,不指定位置,会对数据进行全脱敏 * 例如身份证信息: ...
hive-udfhive自定义函数主要实现hive3种自定义函数1,udf函数,主要用于处理一对一数据处理2,udtf函数,主要用于处理一对多数据处理2,udaf函数,主要用与处理多对一数据聚合处理
详细介绍如何开发hive自定义永久函数,配套有测试数据
Hive自定义函数 一. UDF(user defined function) 背景 系统内置函数无法解决所有的实际业务问题,需要开发者自己编写函数实现自身的业务实现诉求。 应用场景非常多,面临的业务不同导致个性化实现很多,故udf...
NULL 博文链接:https://chengjianxiaoxue.iteye.com/blog/2235666
hive不直接支持分组取TopN的操作,需要自定义udf函数打成jar包添加到hive运行环境中
自定义 hive udf udaf 有url解析,获取网站主域名,根据ip获取区域码,有rownum,列聚合以及一些业务实现udf。
Hive 自定义函数UDF开发手把手教程—— 创建临时函数和永久函数代码,具体创建过程参考https://blog.csdn.net/helloxiaozhe/article/details/102498567
22.Hive中使用自定义UDF实现日期格式转换 23. HiveServer2的介绍及三种连接方式 24.Hive元数据、fetch task和严格模式的介绍 第3章:Sqoop Sqoop及用户行为分析案例 25.CDH版本框架的介绍 26. CDH版本框架的环境...
第 7 章 函数 7.1 系统内置函数 1)查看系统自带的函数 ...2)当 Hive 提供的内置函数无法满足你的业务处理需要时,此时就可以考虑使用用户自定义函数(UDF:user-defined function)。 3)根据用户自定义函数
· 获得创建用户自定义函数(UDF)的最佳方法。 · 了解应该使用的Hive模式以及应该避免的反模式。 · 将Hive和其他数据处理程序进行整合。 · 对于NoSQL数据库和其他数据存储使用存储控制器。 · 学习在亚马逊弹性...
· 获得创建用户自定义函数(UDF)的最佳方法。 · 了解应该使用的Hive模式以及应该避免的反模式。 · 将Hive和其他数据处理程序进行整合。 · 对于NoSQL数据库和其他数据存储使用存储控制器。 · 学习在亚马逊弹性...
同时,Hive也允许熟悉MapReduce开发者们开发自定义的Mappers和Reducers来处理内建的Mappers和Reducers无法完成的复杂的分析工作。Hive还允许用户编写自己定义的函数UDF,用来在查询中使用。;;;6.2 Hive组件架构;6.2 ...
hive入门级详解,包括数仓与传统数据库的比对,hive的存储结构与存储原理,分区分桶、hql如何转换成mapreduce、UDF自定义函数等
在本课程中,你将学习到,Hive架构原理、安装配置、hiveserver2、数据类型、数据定义、数据操作、查询、自定义UDF函数、窗口函数、压缩和存储、企业级调优、以及结合谷粒影音项目需求,把整个Hive的核心知识点贯穿...