如何替换配置单元中的字符? [英] how to replace characters in hive?
问题描述
我在 hive 表中有一个字符串列 description
,其中可能包含制表符 ' '
,但是这些字符在将 hive 连接到外部时会混淆某些视图应用.有没有一种简单的方法可以摆脱该列中的所有制表符?我可以运行一个简单的 python 程序来做到这一点,但我想为此找到一个更好的解决方案.
I have a string column description
in a hive table which may contain tab characters ' '
, 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 执行我的任务.以下是apache Wiki的定义和用法.
regexp_replace
UDF performs my task. Below is the definition and usage from apache Wiki.
regexp_replace(string INITIAL_STRING, string PATTERN, string REPLACEMENT):
这将返回替换 INITIAL_STRING
中的所有子字符串后得到的字符串将 PATTERN
中定义的 java 正则表达式语法与 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
,
例如:regexp_replace("foobar", "oo|ar", "")
返回 fb
这篇关于如何替换配置单元中的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!