Search code examples
snowflake-cloud-data-platform

"File format does not exist or not authorized" error when altering Snowflake stage


I'm creating a Snowflake file format as follows:

create or replace file format "db_name"."schema_name".my_csv_unload_format
  type = 'CSV'
  field_delimiter = ',';

I'm then trying to add this to an existing stage:

alter stage "db_name"."schema_name".my_unloads set
    file_format = (format_name = 'my_csv_unload_format');

However on running this query I get an error:

SQL compilation error: File format 'MY_CSV_UNLOAD_FORMAT' does not exist or not authorized.

I can't see what I'm doing wrong here. Do I need to add some permissions to the file format somewhere?


Solution

  • Worked it out, you also need to specify the database and schema in the format name:

    alter stage "db_name"."schema_name".my_unloads set
        file_format = (format_name = '"db_name"."schema_name".my_csv_unload_format');