当前位置:网站首页>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
- Pat class a 1030 travel plan
- How to configure GDAL under idea
- 【LeetCode】4. Best time to buy and sell stock
- HarmonyOS第三次培训笔记
- 在浏览器输入url后执行什么
- Microsoft Security Response Center
- C2 several methods of merging VCF files
- 【LeetCode】4. Best Time to Buy and Sell Stock·股票买卖最佳时机
猜你喜欢

What is a data type? What is the use of data types?

Iterm2设置

Install cross compiler arm none liunx gnueabihf

【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
![[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18](/img/9b/db5fe1a37e0de5ba363f9e108310a5.png)
[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18

vcs import src < ros2. Repos failed

【MySQL 12】MySQL 8.0.18 重新初始化

What to do after the browser enters the URL

Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction

Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing
随机推荐
在浏览器输入url后执行什么
STM32F103 SPI (pit Diary)
【踩坑系列】mysql 修改root密码失败
Wechat native applet cloud development learning record 01
The difference between hdmi2.1 and hdmi2.0 and the conversion of PD signals.
Enter three times and guess a number
What is definition? What is a statement? What is the difference between them?
Technical dry goods | some thoughts on the future of AI architecture
Go language foundation ------ 12 ------ JSON
Technical dry goods | thinking about the unification of dynamic and static diagrams of AI framework
什么是定义?什么是声明?它们有何区别?
PIP uses image website to solve the problem of slow network speed
OSPF protocol summary
优质博客——
Go language - loop statement
Unity XR realizes interaction (grasping, moving, rotating, transmitting, shooting) -pico
Quality blog——
PostGIS space function
EtherCAT state machine transition (ESM)
What to do after the browser enters the URL