How to remove all characters after a certain character in BigQuery using standard SQL?

Viewed 4836
2 Answers

The easiest way I think is to use SPLIT function as in below example

SPLIT(url, '?')[OFFSET(0)]    

As alternative, you can use REGEXP_EXTRACT as in below example

REGEXP_EXTRACT(url, r'[^?]*')

you can use the REGEXP_EXTRACT function. You will have to create the regexp expression though.

Furthermore, you could use Dataflow to transform the data as another option.

Related