sqlsnowflake-cloud-data-platform

Trim non-breaking white spaces


I am trying to trim Non breaking white space in strings in Snowflake, but looks like the trim() does not support Non-breaking White Space e.g.

select 
  '  test  ' as name -- string with non-breaking white space
  , trim(name);

This does not work. What is the best way to achieve this?


Solution

  • if you put the token's into TRIM it does:

    select 
        'x'|| $1 ||'x' as a, 
        'x'|| trim($1) ||'x' as b, 
        'x'|| trim($1, ' \u202F') ||'x' as c
    from values 
      (' a '),
      ('\u202Fy'),
      ('\u202F z'); 
    

    gives:

    enter image description here