当前位置:网站首页>MaxCompute字符串分割函数-SPLIT_PART
MaxCompute字符串分割函数-SPLIT_PART
2022-07-03 07:51:00 【胜利的曙光】
语法格式
string split_part(string <str>, string <separator>, bigint <start>[, bigint <end>])
函数说明
依照分隔符separator拆分字符串str,返回从start部分到end部分的子串(闭区间)。
参数说明
- str:必填。STRING类型。待拆分的字符串。如果是BIGINT、DOUBLE、DECIMAL或DATETIME类型,则会隐式转换为STRING类型后参与运算。
- separator:必填。STRING类型常量。拆分用的分隔符,可以是一个字符,也可以是一个字符串。
- start:必填。BIGINT类型常量,必须大于0。表示返回段的开始编号(从1开始)。
- end:BIGINT类型常量,大于等于start。表示返回段的截止编号,可省略,缺省时表示和start取值相等,返回start指定的段。
返回值说明
返回STRING类型。返回规则如下:
- 如果start的值大于切分后实际的分段数,例如字符串拆分完有6个片段,start大于6,返回空串。
- 如果separator不存在于str中,且start指定为1,返回整个str。如果str为空串,则输出空串。
- 如果separator为空串,则返回原字符串str。
- 如果end大于片段个数,返回从start开始的子串。
- str非STRING、BIGINT、DOUBLE、DECIMAL或DATETIME类型时,返回报错。
- separator非STRING类型常量时,返回报错。
- start或end非BIGINT类型常量时,返回报错。
- 除separator外,如果任一参数值为NULL,返回NULL。
使用示例
示例1:依照分隔符,
拆分字符串a,b,c,d
,返回指定部分的子串。命令示例如下。
--返回a。
select split_part('a,b,c,d', ',', 1);
--返回a,b。
select split_part('a,b,c,d', ',', 1, 2);
示例2:start的值大于切分后实际的分段数。命令示例如下。
--返回空串。
select split_part('a,b,c,d', ',', 10);
示例3:separator不存在于str中。命令示例如下。
--返回a,b,c,d。
select split_part('a,b,c,d', ':', 1);
--返回空串。
select split_part('a,b,c,d', ':', 2);
示例4:separator为空串。命令示例如下。
--返回a,b,c,d。
select split_part('a,b,c,d', '', 1);
示例5:end的值大于切分后实际的分段数。命令示例如下。
--返回b,c,d。
select split_part('a,b,c,d', ',', 2, 6);
示例6:除separator外,任一输入参数为NULL。命令示例如下。
--返回NULL。
select split_part('a,b,c,d', ',', null);
边栏推荐
- Wechat applet taro learning record
- PostGIS space function
- Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
- Pat grade a 1029 median
- PAT甲级 1031 Hello World for U
- Go language foundation ----- 16 ----- goroutine, GPM model
- How to clear the console password for s7700 device
- Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
- PHP wechat red packet grabbing algorithm
- PHP微信抢红包的算法
猜你喜欢
Redis批量启停脚本
一篇文章让你读懂-曼彻斯特编码
Research shows that breast cancer cells are more likely to enter the blood when patients sleep
【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)
[MySQL 14] use dbeaver tool to remotely backup and restore MySQL database (Linux Environment)
How to configure GDAL under idea
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
研究显示乳腺癌细胞更容易在患者睡觉时进入血液
【cocos creator】点击按钮切换界面
随机推荐
PIP uses image website to solve the problem of slow network speed
PHP common sorting algorithm
华为交换机:配置telnet和ssh、web访问
tp3.2和tp5.0的区别
在浏览器输入url后执行什么
Differences between tp3.2 and tp5.0
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
HarmonyOS第三次培训笔记
Huawei switch console password reset, device initialization, default password
Technology dry goods | Roberta of the migration of mindspore NLP model - emotion analysis task
Go language foundation ----- 11 ----- regular expression
PHP常用排序算法
Harmonyos third training notes
Wechat native applet cloud development learning record 01
haproxy+keepalived搭建01
微软安全响应中心
E: 无法定位软件包 ros-melodic-desktop-full
华为S5700交换机初始化和配置telnet,ssh用户方法
截图工具Snipaste