Skip to content

Instantly share code, notes, and snippets.

@gvisniuc
gvisniuc / snowflake_deduplication_procedure.sql
Last active February 15, 2021 23:19
Snowflake Deduplication Procedure
/*
This procedure will take the full path of a Snowflake table (Database, Schema and Table name) and will deduplicate it using a rotation mechanism.
To minimize waste we first check if the count of the rows of the table is the same as the unique.
If not, given a table A, we create a deduplicated version A_DEDUP.
Table A is renamed to A_ROTATE
A_DEDUP is renamed to A