Does Presto have a function like translate()?

Viewed 801

I need to translate the special characters of a string column into 'raw' characters, using Amazon Presto. In SQL Server, I could do that using the TRANSLATE function:

select
city_name,
translate(city_name,'áéíóúÁÉÍÓÚäëïöüÄËÏÖÜâêîôûÂÊÎÔÛãẽĩõũÃẼĨÕŨ','aeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOU') as cityname_raw
FROM cities

That would return exactly what I need:

city_name

Goiânia
São Paulo
Palhoça
Várzea Paulista

city_name_raw

Goiania
Sao Paulo
Palhoca
Varzea Paulista

Is there an alternative to the TRANSLATE() function in Amazon Presto?

Update:

As suggested, I used lots of nested replaces and it worked out:

replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(name,'ü','u'),'í','i'),'ê','e'),'ú','u'),'õ','o'),'ô','o'),'ç','c'),'é','e'),'ã','a'),'á','a'),'â','a'),'ó','o')

It isn't a pretty query but it works.

1 Answers
Related