1. 1、字符串长度函数:length(X)(返回字符串X的长度)
  2. select length('qwerty') from table --6
  3.  
  4. 2、字符串反转函数:reverse(X)(返回字符串X反转的结果)
  5. select reverse('qwerty') from table --ytrewq
  6.  
  7. 3、字符串连接函数:concat(X,Y,...)(返回输入字符串连接后的结果,支持任意个输入字符串连接)
  8. select concat('abc','qwe','rty') from table --abcqwerty
  9.  
  10. 4、带分隔符字符串连接函数:concat_ws(X,y,Z)(返回输入字符串连接后的结果,X表示各个字符串间的分隔符)
  11. select concat_ws('/','abc','qwe','rty') from table --abc/qwe/rty
  12.  
  13. 5、字符串截取函数:substr(X,Y,Z)/substring(X,Y,Z)(返回字符串XY位置开始,截取长度为Z的字符串)
  14. select substr('qwerty',1,3) from table --qwe
  15.  
  16. 6、字符串转大写函数:upper(X)/ucase(X)(返回字符串X的大写格式)
  17. select upper('qwERt') from table --QWERT
  18. select ucase('qwERt') from table --QWERT
  19.  
  20. 7、字符串转小写函数:lower(X)/lcase(X)(返回字符串X的小写格式)
  21. select lower('qwERt') from table --qwert
  22. select lcase('qwERt') from table --qwert
  23.  
  24. 8、去空格函数:trim(X)(去除X字符串两边的空格)
  25. select trim(' qwe rty uiop ') from table --'qwe rty uiop'
  26. 左边去空格函数:ltrim(X)(去除X字符串左边的空格)
  27. select ltrim(' qwe rty uiop ') from table --'qwe rty uiop '
  28. 右边去空格函数:rtrim(X)(去除X字符串右边的空格)
  29. select rtrim(' qwe rty uiop ') from table --' qwe rty uiop'
  30.  
  31. 9、正则表达式替换函数:regexp_replace(X,Y,Z)(将字符串X中的符合java正则表达式Y的部分替换为Z:将X中与Y相同的字符串用Z替换)
  32. select regexp_replace('foobar', 'o|ar', '234') from table --f234234b234
  33.  
  34. 10、正则表达式解析函数:regexp_extract(X,Y,Z)(将字符串X按照Y正则表达式的规则拆分,返回Z指定的字符)
  35. select regexp_extract('foothebar', 'foo(.*?)bar', 0) from table --foothebar
  36. select regexp_extract('foothebar', 'foo(.*?)bar', 1) from table --the
  37. select regexp_extract('foothebar', 'foo(.*?)bar', 2) from table --bar
  38.  
  39. 11URL解析函数:parse_url(X,Y,Z)(返回URL中指定的部分。X的有效值为:HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO
  40. select parse_url('https://www.iteblog.com/path1/p.php?k1=v1&k2=v2#Ref1', 'HOST') from table --www.iteblog.com
  41. select parse_url('https://www.iteblog.com/path1/p.php?k1=v1&k2=v2#Ref1', 'QUERY','k1') from table --v1
  42.  
  43. 12json解析函数:get_json_object(X,Y)(解析json的字符串X,返回Y指定的内容)
  44. 例:X='[{"height":540,"size":79466,"width":960,"card_info":{"title":"超火热门小说","mp_tag_type":0,"head_desc_type":2,"pure_color_rgb":"#643C15","font_color":"#FFFFFF"}}]'
  45. select get_json_object(substr(X,2,length(crt_info)-2), '$.card_info.pure_color_rgb') as color_rgb from table --#643C15
  46. select get_json_object(substr(X,2,length(crt_info)-2), '$.size') as size_ from table --79466
  47.  
  48. 13、空格字符串函数:space([int] X)(返回长度为X的字符串)
  49. select space(10) from table --空
  50. select length(space(10)) from table --10
  51.  
  52. 14、重复字符串函数:repeat(X,Y)(返回重复Y次后的X字符串)
  53. select repeat('abc',3) from table --abcabcabc
  54.  
  55. 15、首字符ascii函数:ascii(X)(返回字符串X首字符的ascii码)
  56. select ascii('abcde') from table --97
  57.  
  58. 16、左补足函数:lpad(X,Y,Z)(将字符串X左补足到Y位:将字符串Z填充在字符串X的左边,直至字符串长度为Y
  59. 备注:左补足时,补足的字符串Z要倒序补足
  60. select lpad('abc',6,'wq') from table --wqwabc
  61. 右补足函数:rpad(X,Y,Z)(将字符串X右补足到Y位:将字符串Z填充在字符串X的右边,直至字符串长度为Y
  62. select rpad('abc',6,'wq') from table --abcwqw
  63.  
  64. 17、分割字符串函数: split(X,Y)(将字符串X按照Y字符串进行分割,返回分割后的字符串数组)
  65. select split('abcabcabc','b') from table --["a","ca","ca","c"]
  66.  
  67. 18、集合查找函数: find_in_set(X,Y)(返回XY第一次出现的位置,Y是用逗号分割的字符串。如果没有找该X字符,则返回0
  68. select find_in_set('as','ad,af,as,ag') from table --3
  69. select find_in_set('ak','ad,af,as,ag') from table --0
  70.  
  71. 19str_to_map()
  72. 例:str='aid=>31201343148,amsfirstcategoryid=>214748336535,amsfirstcategoryname=>服饰鞋帽箱包,city_level=>1,corporation=>杭州女王轻奢网络科技有限公司,crt_size=>666,end_time=>20210316,name=>新款棉麻专物,secondcategoryname=>服饰鞋包综合,snsid=>135498092586548652538,source=>1,spid=>spid37a67b6f563,spname=>天津太古时代网络技术有限公司'
  73. select string_to_map(str ,",","=>")["aid"] as aid from table --aid

Hive常用函数大全-字符串函数的更多相关文章

  1. SQL函数大全(字符串函数).

    SQL Server 2005  函数大全 字符串函数 字符串函数 SubString在SQL和C#中不同, 一,select  substring('abcde',-1,3) select LEN( ...

  2. ORACLE常用数值函数、转换函数、字符串函数介绍

    ORACLE常用数值函数.转换函数.字符串函数介绍. 数值函数: abs(m) m的绝对值 mod(m,n) m被n除后的余数 power(m,n) m的n次方 round(m[,n]) m四舍五入至 ...

  3. SQL serve 聚合函数、字符串函数

    1.聚合函数 sum,avg,max,min,count        having后面只能跟聚合函数 2.数学函数和字符串函数 3.练习: 1)新建一个学生信息表,根据问题写出程序. 2)新建一个超 ...

  4. SQL server聚合函数、数学函数、字符串函数

    一.基础语句 二.数学函数与字符串函数 三.练习 1.创建一个学生信息表,根据要求写出程序 2.新建一个超市表,进了十种商品,个数都是十件

  5. SQL server 数据库——数学函数、字符串函数、转换函数、时间日期函数

    数学函数.字符串函数.转换函数.时间日期函数 1.数学函数 ceiling()--取上限  select ceiling(oil) as 油耗上限 from car floor()--取下限 sele ...

  6. SQL Server系统函数:字符串函数

    原文:SQL Server系统函数:字符串函数 1.字符转化为ASCII,把ASCII转化为字符,注意返回的值是十进制数 select ASCII('A'),ASCII('B'),ASCII('a') ...

  7. hive函数总结-字符串函数

    hive 查看函数: show  functions; parse_url: parse_url(url, partToExtract[, key]) - extracts a part from a ...

  8. hive自带的字符串函数

    1. 字符串长度函数:length 语法: length(string A) 返回值: int 说明:返回字符串A的长度 举例: hive> select length('abcedfg') f ...

  9. sql常用格式化函数及字符串函数

    一.常用格式化函数 1.日期转字符串 select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') YYYY:年份 MM:月份号(01-12) ...

随机推荐

  1. 桥接模式(Bridge模式)

    桥接模式的定义与特点 桥接(Bridge)模式的定义如下:将抽象与实现分离,使它们可以独立变化.它是用组合关系代替继承关系来实现,从而降低了抽象和实现这两个可变维度的耦合度.通过上面的讲解,我们能很好 ...

  2. 浅谈kali : arpspoof工具原理

    Arpspoof工具 介绍 arpspoof是一个通过ARP协议伪造数据包实现中间人攻击的kali工具. 中间人攻击虽然古老,但仍处于受到黑客攻击的危险中,可能会严重导致危害服务器和用户.仍然有很多变 ...

  3. Redis 学习笔记(一)redis 数据类型和对象机制

    Redis 简介 Redis 是(key-value)的 NoSQL 数据库,所有的 key 都是 String ,它的 value 可以是 String.hash.list.set.zset(有序集 ...

  4. vue之keep-alive的使用

    keep-alive:是vue内置的一个组件,可以使被包含的组件保留状态或避免重新渲染.有两个生命周期函数:activated.deachtivated.在vue 2.1.0版本后新增了两个属性:in ...

  5. Git配置用户信息和SSH免密

    一.配置用户信息 1.查看配置信息 # 查看所有配置 $ git config -l/--list # 查看系统配置 $ git config --system -l/--list # 查看用户配置 ...

  6. react-motion 动画案例介绍

    第一个案例:Motion组件 import React,{Component} from 'react'; import {Motion,spring,presets} from 'react-mot ...

  7. bom案例2-弹出层

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  8. 【VUE】vue中遍历数组和对象

    一.遍历对象 对象数据 cities:{ "A":[{ "id": 56, "spell": "aba", " ...

  9. Lua 语言: 语法

    转载请注明来源:https://www.cnblogs.com/hookjc/ -- 两个横线开始单行的注释 --[[  加上两个[和]表示     多行的注释.--]] -------------- ...

  10. MySQL高质量博文链接集合

    1. 『浅入浅出』MySQL 和 InnoDB https://draveness.me/mysql-innodb.html