I'm trying to strip accents from UTF string. Normalization function doesn't seem to work in BigQuery's Javascript UDF. I've tested the same function in browser and it gives me right results.
BigQuery has built in normalization function and it works fine, but why doesn't it work within Javascript UDF? Is this behavior expected? What could be the reason?
Example query:
CREATE TEMP FUNCTION normAndRepl(s STRING) RETURNS STRING LANGUAGE js AS """
return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
""";
CREATE TEMP FUNCTION repl(s STRING) RETURNS STRING LANGUAGE js AS """
return s.replace(/[\u0300-\u036f]/g, '')
""";
SELECT repl(normalize('München', NFD)), normAndRepl('München')
The results are as expected in left column, but not necessarily in right one.
f0_ | f1_
--------+--------
Munchen | München