Hive 中 Presto REPLACE 函数的等价物

Equivalent of Presto REPLACE function in Hive

我目前有一个状况,如下所示

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 是您可以使用的命令。您可以将要替换的子字符串列表作为由“|”分隔的列表并且您需要使用 '\' 来提供任何可能充当通配符的特殊字符,例如 - 。要么 ?或 * 等。下面是示例用法。

SELECT regexp_replace(upper(fieldname),'LTD|QMT|INTERNATIONAL|ORG|INC|\.|,| ','') from my_table;