I am trying to rename an external Stage file using Snowflake.
copy files into @targetstage/newfilename from @inputstage.
The result is NewfilenameCurrentFilename
.
I want only new file name. Can anybody please suggest a workaround?
If renaming via SQL is mandatory and you're okay going through a table:
Load the file into a temporary table.
Use COPY INTO @targetstage/newfilename.csv
to export.
-- Step 1: Load to table
COPY INTO my_temp_table FROM @inputstage;
-- Step 2: Export with desired filename
COPY INTO @targetstage/newfilename.csv FROM my_temp_table FILE_FORMAT = (TYPE = CSV);