I have a column called still_available
with the values of 'Removed' and 'Still_available'. The original table looks like this:
Since there are only two values I want to cast it to boolean
e.g 'Removed' => False and 'Still_available' => True. So I did this:
dim_products_set_still_available_to_bool = f"""
UPDATE public.dim_products
SET still_available =
CASE
WHEN still_available = 'Removed' THEN {False}
ELSE {True}
END;
"""
On row 4 it sets the value to true
. I was expecting the rows to be set properly to the new values so I can cast the column datatype to boolean
.
I'm not sure why but once I copied the actual string from the database it seems to work completely with:
dim_products_set_still_available_to_bool = f"""
UPDATE public.dim_products
SET still_available =
CASE
WHEN still_available = 'Removed' THEN {False}
WHEN still_available = 'Still_avaliable' THEN {True}
END;
"""