相当于 Hive 中的 Presto REPLACE 功能

问题描述

我目前有如下状况

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'

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...