amazon-redshift-utils
amazon-redshift-utils copied to clipboard
sp_pivot_for needs to handle empty sets gracefully
sp_pivot_for will run into an issue with the dynamic sql when it tries to pivot and there are no rows in the pivot table.
To reproduce this you can run one of the example CALLs in the SP but truncate the table ahead of time.
A solution could just be to run a quick count(*) on the source table and return an error if the value = 0