如何替换蜂巢中的字符? [英] how to replace characters in hive?

查看:154
本文介绍了如何替换蜂巢中的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个可能包含制表符'\ t'的配置单元表中有一个字符串列 description ,但是,将这些配置单元连接到外部应用程序时,这些字符会混淆某些视图。
是否有一种简单的方法来摆脱该列中的所有制表符?我可以运行一个简单的python程序来做到这一点,但我想找到一个更好的解决方案。

解决方案

regexp_replace UDF执行我的任务。

  regexp_replace(string INITIAL_STRING,string PATTERN,string REPLACEMENT):

这将返回替换 INITIAL_STRING $中的所有子字符串b $ b,它与 PATTERN 中定义的java正则表达式语法匹配, REPLACEMENT ,



例如: regexp_replace(foobar,oo | ar,)返回 fb


I have a string column description in a hive table which may contain tab characters '\t', these characters are however messing some views when connecting hive to an external application. is there a simple way to get rid of all tab characters in that column?. I could run a simple python program to do it, but I want to find a better solution for this.

解决方案

regexp_replace UDF performs my task. Below is the definition and usage from apache Wiki.

regexp_replace(string INITIAL_STRING, string PATTERN, string REPLACEMENT):

This returns the string resulting from replacing all substrings in INITIAL_STRING that match the java regular expression syntax defined in PATTERN with instances of REPLACEMENT,

e.g.: regexp_replace("foobar", "oo|ar", "") returns fb

这篇关于如何替换蜂巢中的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆