语法: 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"


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案