hive 查看函数:

show  functions;

parse_url:

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来返回特定参数,例如
* parse_url('http://facebook.com/path/p1.php?query=1', 'QUERY','query')返回'1',

* 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'

正则表达式替换函数: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
正则表达式解析函数: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
URL解析函数:parse_url
语法: parse_url(string urlString, string partToExtract [, 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
json解析函数:get_json_object
语法: 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

如request ={“store”: {“fruit”:\[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}],  “bicycle”:{“price”:19.95,”color”:”red”}  }

>get_json_object(request,'$.weight')

8

空格字符串函数:space
语法: space(int n) 
返回值: string
说明:返回长度为n的字符串
举例:
hive> select space(10) from dual;
hive> select length(space(10)) from dual;
10
重复字符串函数:repeat
语法: repeat(string str, int n) 
返回值: string
说明:返回重复n次后的str字符串
举例:
hive> select repeat(‘abc’,5) from dual;
abcabcabcabcabc
首字符ascii函数:ascii
语法: ascii(string str) 
返回值: int
说明:返回字符串str第一个字符的ascii码
举例:
hive> select ascii(‘abcde’) from dual;
97
左补足函数:lpad
语法: lpad(string str, int len, string pad) 
返回值: string
说明:将str进行用pad进行左补足到len位
举例:
hive> select lpad(‘abc’,10,’td’) from dual;
tdtdtdtabc
与GP,ORACLE不同,pad 不能默认
右补足函数:rpad
语法: rpad(string str, int len, string pad) 
返回值: string
说明:将str进行用pad进行右补足到len位
举例:
hive> select rpad(‘abc’,10,’td’) from dual;
abctdtdtdt
分割字符串函数: split
语法:  split(string str, string pat) 
返回值:  array
说明: 按照pat字符串分割str,会返回分割后的字符串数组
举例:
hive> select split(‘abtcdtef’,'t’) from dual;
["ab","cd","ef"]
集合查找函数: find_in_set
语法: find_in_set(string str, string strList) 
返回值: int
说明: 返回str在strlist第一次出现的位置,strlist是用逗号分割的字符串。如果没有找该str字符,则返回0
举例:
hive> select find_in_set(‘ab’,'ef,ab,de’) from dual;
2
hive> select find_in_set(‘at’,'ef,ab,de’) from dual;
0

hive函数总结-字符串函数的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

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

  7. 【HIVE】(3)联合查询join、时间戳函数、字符串函数

    数据 t_join1.txt 1,a,1 2,b,2 3,c,4 t_join2.txt 1,2a 2,2b 3,2c 建表.导入: create table t_join1(id int, name ...

  8. Hive常用函数大全-字符串函数

    1.字符串长度函数:length(X)(返回字符串X的长度) select length('qwerty') from table --6 2.字符串反转函数:reverse(X)(返回字符串X反转的 ...

  9. SQLSERVER常见系统函数之字符串函数(一)

    好久没有写博客了,这段时间准备写一下字符串函数 QQ群: 499092562:欢迎交流 字符串函数: 1.LEN(需要获取长度的字符串) 返回:字符串的长度 示例: SELECT LEN('小搬运工很 ...

随机推荐

  1. 武汉科技大学ACM :1001: A + B Problem

    Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to e ...

  2. Java Se 基础系列(笔记) -- Exception && Array

    Exception 1.java 异常是java提供的用于处理程序中错误(指在程序运行的过程中发生的一些异常事件)的一种机制 2.java程序的执行过程中如果发生异常事件则自动生产一个异常类对象,该对 ...

  3. Matlab 取子矩阵

    MATLAB如何提取矩阵的子块 在matlab中如何提取一个矩阵的部分元素 1.提取大矩阵的一列.一行元素: 一列元素:  A(:,j)表示提取A矩阵的第j列全部元素 一行元素:  A(i,:)表示提 ...

  4. mysql 5.6 参数详解

    系统变量提供的是各种与服务器配置和功能有关的信息.大部分的系统变量都可以在服务器启动时进行设置.在运行时,每一个系统变量都拥有一个全局值或会话值,或者同时拥有这两个值.许多系统变量都是动态的,也就是说 ...

  5. 标准程序员系列-Github篇-初始化一个代码仓库

    下面将一步步介绍怎样使用GitHub来初始化一个项目的版本控制仓库: 1. 到GitHub上注册自己的账号:https://github.com/ 2. 创建第一个代码仓库一个仓库相当于一个项目的代码 ...

  6. 重写Collections实现自定义排序

    Collections.sort(List<Object>, new Comparator<Object>() { public int compare(Object o1, ...

  7. Python入门-----Windows安装

    摘要:Python,windows安装 1.进入python的官方网站下载:https://www.python.org 点击Download,选择windows版本:

  8. IIC 概述之源码仿真

    7.1.1 I2C总线简介 1.I2C总线的基本结构 I2C总线由数据线SDA和时钟线SCL构成,每条线都通过上拉电阻接向正电源,所有采用I2C接口标准的器件均并行挂接在总线上,如图7-1所示. I2 ...

  9. AndroidStudio push代码到github

    步骤 1 studio的git配置: 安装好git后启动Androidstudio,打开如下路径File->Settings->Version Control(展开)->git 在P ...

  10. Android相关类关系

    Activity Window.WindowManager View. interface----ViewManager LayoutInflater Components Activity.Serv ...