Search code examples
google-bigquerytrim

'TRIM' or 'PROPER' in BigQuery


is there a way to normalize strings in BigQuery?

My dataset looks like:

Alfa Beta

Alfa BETA

alfa beta //with a space after 'beta'

By now I can use lower or upper to normalize the letters but I don't know how to eliminate spaces before and after the text. Does BigQuery have a function like 'TRIM' in Excel?


Solution

  • BigQuery does have LTRIM (trims spaces from left) and RTRIM (trims spaces from right) functions. (Strings functions documentation at https://cloud.google.com/bigquery/query-reference#stringfunctions missed them, we will fix this shortly).