hive - split函数(分割字符串)

语法: split(string str, string pat)
返回值: array
说明: 按照pat字符串分割str,会返回分割后的字符串数组
举例:
1.基本用法

hive> select split('abcdef', 'c') from test;
["ab", "def"]
2.截取字符串中的某个值

hive> select split('abcdef', 'c')[0] from test;
ab
3.特殊字符
如正则表达式中的特殊符号作为分隔符时,需做转义 (前缀加上\)

hive> select split('ab_cd_ef', '\_')[0] from test;
ab
hive> select split('ab?cd_ef', '\\?')[0] from test;
ab
如果是在shell中运行,则(前缀加上\\)

hive -e "select split('ab?cd_ef', '\\\\?')[0] from test"


上一篇:使用benchmarkSQL测试数据库的TPCC


下一篇:sysbench 压测