Convert name with accents to name without accent using HIVE

Viewed 35

I am trying to pass names with accents, for example: sŕodigër to names without accents: srodiger. I'm sure there has to be a way to do it, but I didn't find it.

I'm trying this, but it's crazy to do it with consonants too:

    concat(CASE WHEN m.first_names IS NOT NULL THEN 
replace(name, 'âãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮ',
    'aaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuu') 
    ELSE '' END

How could I do it?

1 Answers

Pls use translate().

   concat(CASE WHEN m.first_names IS NOT NULL THEN 
translate(name, 'âãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮ',
    'aaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuu') 
    ELSE '' END

In below example, it successfully replaced ascents with whatever you want to replace them with. Exampleenter image description here

Related