Redshift Bulk Upsert - how does it work?

How does the Redshift Bulk Upsert work underneath the covers? For example, I know that the Redshift Bulk Load snap writes the data to S3 and then executes a Redshift COPY command to load the data from S3 to the Redshift table. How does the Redshift Bulk Upsert work?

The snap bulk loads the data into a temporary table, and then does the update and insert operations, followed by the removal of the intermediate staging table.

Thanks @cstewart - so the Redshift user must also have create table permission.