sqlmesh
sqlmesh copied to clipboard
[Redshift] Check Distkey and Sortkey before Altering Table
Due to Redshift's auto table optimization it is possible that a user would have a forward-only table that needs to have a column dropped that is part of the distkey or sortkey. Therefore before performing alter operations on Redshift we should check if we are dropping a distkey/sortkey and if so we should change the distkey/sortkey to auto and then alter.
In the case where there is a type change we should test but it would likely involve changing to auto and then changing it back once done.