As you can see, the only column thats throwing error here is user_uuid
I want it to have datatype uuid. Previously before loading the data it was of the type object in python.
Simplified problem:
ALTER TABLE dim_users
ALTER COLUMN user_uuid TYPE UUID USING (user_uuid::UUID);
ERROR:
ERROR: invalid input syntax for type uuid: "abc"

If your values are indeed
UUID-compatible, then something like this works:so in that case your script should work. It will work with nulls as well:
but it won't work by itself on values that cannot be converted into uuid:
so you have some values that cannot be converted into
uuid. So, we need to determine whether a value is a properuuid, convert it touuidin that case and default tonullotherwise:Nice, is it not?
You are of course well-advised to back up your data before doing this and carefully check the results.