1. 字符串长度函数：length

hive> select length('abcedfg') from lxw_dual;

7

2. 字符串反转函数：reverse

hive> select reverse(abcedfg’) from lxw_dual;

gfdecba

3. 字符串连接函数：concat

hive> select concat(‘abc’,'def’,'gh’) from lxw_dual;

abcdefgh

4. 带分隔符字符串连接函数：concat_ws

hive> select concat_ws(',','abc','def','gh') from lxw_dual;

abc,def,gh

5. 字符串截取函数：substr,substring

hive> select substr('abcde',3) from lxw_dual;

cde

hive> select substring('abcde',3) from lxw_dual;

cde

hive>  selectsubstr('abcde',-1) from lxw_dual;  （和ORACLE相同）

e

6. 字符串截取函数：substr,substring

hive> select substr('abcde',3,2) from lxw_dual;

cd

hive> select substring('abcde',3,2) from lxw_dual;

cd

hive>select substring('abcde',-2,2) from lxw_dual;

de

7. 字符串转大写函数：upper,ucase

hive> select upper('abSEd') from lxw_dual;

ABSED

hive> select ucase('abSEd') from lxw_dual;

ABSED

8. 字符串转小写函数：lower,lcase

hive> select lower('abSEd') from lxw_dual;

absed

hive> select lcase('abSEd') from lxw_dual;

absed

9. 去空格函数：trim

hive> select trim(' abc ') from lxw_dual;

abc

10. 左边去空格函数：ltrim

hive> select ltrim(' abc ') from lxw_dual;

abc

11. 右边去空格函数：rtrim

hive> select rtrim(' abc ') from lxw_dual;

abc

12. 正则表达式替换函数：regexp_replace

hive> select regexp_replace('foobar', 'oo|ar', '') from lxw_dual;

fb

13. 正则表达式解析函数：regexp_extract

hive> select regexp_extract('foothebar', 'foo(.*?)(bar)', 1) fromlxw_dual;

the

hive> select regexp_extract('foothebar', 'foo(.*?)(bar)', 2) fromlxw_dual;

bar

hive> select regexp_extract('foothebar', 'foo(.*?)(bar)', 0) fromlxw_dual;

foothebar

select data_field,

regexp_extract(data_field,'.*?bgStart\\=([^&]+)',1) as aaa,

where pt = '2012-03-26'limit 2;

14. URL解析函数：parse_url

v1

15. json解析函数：get_json_object

hive> select get_json_object('{"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"

> }

> ','\$.owner') from lxw_dual;

amy

16. 空格字符串函数：space

hive> select space(10) from lxw_dual;

hive> select length(space(10)) from lxw_dual;

10

17. 重复字符串函数：repeat

hive> select repeat('abc',5) from lxw_dual;

abcabcabcabcabc

18. 首字符ascii函数：ascii

hive> select ascii('abcde') from lxw_dual;

97

tdtdtdtabc

abctdtdtdt

21. 分割字符串函数: split

hive> select split('abtcdtef','t') from lxw_dual;

["ab","cd","ef"]

22. 集合查找函数:find_in_set

hive> select find_in_set('ab','ef,ab,de') from lxw_dual;

2

hive> select find_in_set('at','ef,ab,de') from lxw_dual;

0