Issue
When attempting to upload files to Snowflake using the PUT command, the process fails if the same file name is reused for multiple uploads. The second upload is skipped, and the file is not replaced.
This behavior occurs because Snowflake does not overwrite existing staged files by default and skips the PUT command when the destination file name already exists.
Cause
Snowflake does not overwrite existing staged files by default and skips PUT when the destination file name already exists
Solution
To resolve this issue, you can implement one of the following approaches:
- Force overwrite in the PUT command:
PUT file:///path/to/file @stage_name AUTO_COMPRESS=TRUE OVERWRITE=TRUE; - Remove the existing file before uploading:
REMOVE @stage_name 'file_name'; PUT file:///path/to/file @stage_name AUTO_COMPRESS=TRUE; - Use unique file names by generating unique names (e.g., using a timestamp or execution ID) instead of reusing the same generic file name.