Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 571 Bytes

replace-empty-strings-null.md

File metadata and controls

24 lines (18 loc) · 571 Bytes

Replace empty strings with NULLs

Explore this snippet here.

Description

An essential part of cleaning a new data source is deciding how to treat missing values. The BigQuery function IF can help with replacing empty values with something else:

with data as (
  select * from unnest(['a', 'b', '', 'd']) as str
)

select
  if(length(str) = 0, null, str) str
from data
str
a
b
NULL
d