Why does my BigQuery UPDATE fail when replacing 0 values with NULL using CASE statements?

Kaptek
Updated 7 hours ago in

I’m cleaning a weather dataset in Google BigQuery where missing values in wind_speed and visibility were incorrectly stored as 0.

I tried updating the table like this:

 
 
UPDATE `my_project.weather_data.tracks_2023`
SET
wind_speed = CASE WHEN wind_speed = 0 THEN NULL END,
visibility = CASE WHEN visibility = 0 THEN NULL END
WHERE wind_speed = 0 OR visibility = 0;
 

The query returns an error.

My goal is simple:

  • Convert 0 values in wind_speed to NULL
  • Convert 0 values in visibility to NULL
  • Leave all other values unchanged

What’s the correct way to do this in BigQuery?

  • 0
  • 3
  • 7 hours ago
 
Loading more replies