Hive中的replace方法
Hive本身并没有replace方法,但是提供了两个方法可以实现replace功能
- translate
- regexp_replace
translate例子
使用空字符串替换#字符
> select translate('This #is test to verify# translate #Function in Hive', '#','');
+----------------------------------------------------+--+
| _c0 |
+----------------------------------------------------+--+
| This is test to verify translate Function in Hive |
+----------------------------------------------------+--+
1 row selected (0.28 seconds)
这个方法可用是在Hive 0.10.0
但是只针对单个字符,多字符会出错
select translate('hello','llo','a')得到heaa
regexp_replace例子
使用$符号替换^
版权声明:本文为someInNeed原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。