美文网首页
hive字符串函数

hive字符串函数

作者: 尤小闹 | 来源:发表于2018-06-07 11:53 被阅读0次

1.regexp_replace 正则表达式替换函数

语法: regexp_replace(string A, string B, string C)

返回值: string

说明:将字符串A中的符合java正则表达式B的部分替换为C。注意,在有些情况下要使用转义字符

hive> select regexp_replace(‘foobar’, ‘oo|ar’, ”) from dual;
fb

2.regexp_extract 正则表达式解析函数

语法: regexp_extract(string subject, string pattern, int index)

返回值: string

说明:将字符串subject按照pattern正则表达式的规则拆分,返回index指定的字符。注意,在有些情况下要使用转义字符

hive> select regexp_extract(‘foothebar’, ‘foo(.*?)(bar)’, 1) from dual;
the
hive> select regexp_extract(‘foothebar’, ‘foo(.*?)(bar)’, 2) from dual;
bar
hive> select regexp_extract(‘foothebar’, ‘foo(.*?)(bar)’, 0) from dual;
foothebar

3.parse_url URL解析函数

语法: parse_url(string urlString, stringpartToExtract [, string keyToExtract])

返回值: string

说明:返回URL中指定的部分。partToExtract的有效值为:HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO.

hive> select parse_url(‘http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1′, ‘HOST’) from dual;
facebook.com
hive> select parse_url(‘http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1′, ‘QUERY’, ‘k1′) from dual;
v1

4.get_json_object json解析函数

语法: get_json_object(string json_string, string path)

返回值: string

说明:解析json的字符串json_string,返回path指定的内容。如果输入的json字符串无效,那么返回NULL。

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 dual;

amy

相关文章

  • Hive自定义函数

    一、hive为我们提供的函数 hive给我们提供了一些内置函数,比如截取字符串,大小写转换此处距离substr 1...

  • hive - concat 函数

    concat 函数 concat 函数在连接字符串的时候,只要其中一个是NULL,那么将返回NULL hive>...

  • hive字符串函数

    1.regexp_replace 正则表达式替换函数 语法: regexp_replace(string A, s...

  • 大数据开发之Hive篇6-Hive函数详解

    备注:Hive 版本 2.1.1 一.Hive函数概述 1.1 Hive函数分类 函数/UDF输入一行记录,输出一...

  • Hive 自定义函数

    系统内置函数 查看系统内置函数hive> show functions;显示内置函数用法hive> desc fu...

  • 利用Python替换Hive查询语句中的变量

    Hive查询语句可以看作一个较长的字符串,因此可以用字符串替换函数来修改成其他查询语句。使用Python等编程工具...

  • Hive函数

    hive中的函数从大体上可以分为两类:hive内置函数和用户自定义函数 hive内置函数又可以根据输入输出细分为以...

  • Hive自定义UDF UDAF UDTF

    hive允许用户使用自定义函数解决hive 自带函数无法处理的逻辑。hive自定义函数只在当前线程内临时有效,可以...

  • HIVE UDTF 自定义函数

    HIVE UDTF 自定义函数 关键词:HIVE UDTF 开发 实例Hive运行用户自定义函数对数据信息处理,...

  • Hive sql常见操作

    基本sql操作 hive表操作 分区操作 Hive内置函数 (1)数学函数 常用的数学函数都有:round、flo...

网友评论

      本文标题:hive字符串函数

      本文链接:https://www.haomeiwen.com/subject/tqxgsftx.html