问题描述
我目前有如下状况
replace(replace(replace(replace(replace(replace(replace(replace(UPPER(FIELDNAME),' ',''),'LLC','INC','INTERNATIONAL','LTD','.',','QMT','')
在 Hive 中实现完全相同目的的等效函数是什么? regexp_replace 是否适用于上述情况?
在上述条件中使用 regexp_replace 而不是替换,但它抛出了以下错误。
Failed: SemanticException [Error 10014]: Line 1:255 Wrong arguments ''('': No matching method for class org.apache.hadoop.hive.ql.udf.UDFregexpReplace with (string,string). Possible choices: _FUNC_(string,string,string) (state=42000,code=10014)
如果有人能对此提供帮助,那就太好了。谢谢
解决方法
确实如此。 regexp_replace 是您可以使用的命令。您可以将要替换的子字符串列表指定为由“|”分隔的列表并且您需要使用 '\' 来提供任何可能充当通配符的特殊字符,例如 - 。要么 ?或 * 等。以下是示例用法。
AttributeError: 'str' object has no attribute 'items'