createFileFormat

Creates a new file format in Snowflake. File formats define how data files should be parsed when loading or unloading data.

Note: Automatic rollback drops the file format.

Available attributes

Attribute

Type

Description

Required

catalogName

String

Name of the catalog (database) where the file format will be created

No

schemaName

String

Name of the schema where the file format will be created

No

fileFormatName

String

Name of the file format to create

Yes

fileFormatType

String

Type: CSV, JSON, AVRO, ORC, PARQUET, XML, or CUSTOM

No

comment

String

Comment describing the file format

No

replaceIfExists

Boolean

Replace the file format if it already exists using OR REPLACE

No

alterIfExists

Boolean

Alter the file format if it already exists using ALTER IF EXISTS

No

ifNotExists

Boolean

Only create if the file format doesn't exist using IF NOT EXISTS*

No

temporary

Boolean

Create a temporary file format

No

* replaceIfExists, alterIfExists, and ifNotExists are mutually exclusive

formatTypeOptions attributes

Attribute

Type

Description

Required

key

String

Format-specific option name (e.g., COMPRESSION)

Yes

value

String

Option value

Yes

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:pro-snowflake="http://www.liquibase.org/xml/ns/pro-snowflake"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
        http://www.liquibase.org/xml/ns/pro-snowflake
        http://www.liquibase.org/xml/ns/pro-snowflake/liquibase-pro-snowflake-latest.xsd">
  <!-- Create CSV file format with options -->
  <changeSet id="create-file-format-csv" author="examples">
    <pro-snowflake:createFileFormat
                fileFormatName="CSV_FORMAT"
                fileFormatType="CSV"
                ifNotExists="true"
                comment="CSV file format for data imports">
      <pro-snowflake:formatTypeOptions>
        <pro-snowflake:entry key="COMPRESSION" value="ZSTD"/>
        <pro-snowflake:entry key="FIELD_DELIMITER" value=","/>
        <pro-snowflake:entry key="SKIP_HEADER" value="1"/>
      </pro-snowflake:formatTypeOptions>
    </pro-snowflake:createFileFormat>
  </changeSet>
  <!-- Create JSON file format -->
  <changeSet id="create-file-format-json" author="examples">
    <pro-snowflake:createFileFormat
                fileFormatName="JSON_FORMAT"
                fileFormatType="JSON"
                replaceIfExists="true"
                comment="JSON file format">
      <pro-snowflake:formatTypeOptions>
        <pro-snowflake:entry key="COMPRESSION" value="AUTO"/>
        <pro-snowflake:entry key="STRIP_OUTER_ARRAY" value="TRUE"/>
      </pro-snowflake:formatTypeOptions>
    </pro-snowflake:createFileFormat>
  </changeSet>
  <!-- Create temporary Parquet file format -->
  <changeSet id="create-file-format-parquet" author="examples">
    <pro-snowflake:createFileFormat
                fileFormatName="TEMP_PARQUET_FORMAT"
                fileFormatType="PARQUET"
                temporary="true"/>
  </changeSet>
  <!-- Create or alter file format -->
  <changeSet id="create-file-format-alter-if-exists" author="examples">
    <pro-snowflake:createFileFormat
                fileFormatName="AVRO_FORMAT"
                fileFormatType="AVRO"
                alterIfExists="true"
                comment="AVRO format - creates or alters if exists"/>
  </changeSet>
</databaseChangeLog>