Snowflake

Snowflake File Formats Design Guide: Optimal Settings for CSV, JSON, Parquet

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

File Format is a reusable object that defines the file type and parse options used when loading data into Snowflake (COPY INTO <table>) or unloading it (COPY INTO <location>). It supports five formats — CSV, JSON, Parquet, Avro, and ORC — and lets you centrally manage format-specific options (delimiters, compression, error handling, etc.).

Creating a CSV File Format

-- Basic CSV File Format
CREATE OR REPLACE FILE FORMAT util_db.formats.csv_standard
  TYPE = 'CSV'
  FIELD_DELIMITER = ','
  RECORD_DELIMITER = '\n'
  SKIP_HEADER = 1
  FIELD_OPTIONALLY_ENCLOSED_BY = '"'
  NULL_IF = ('NULL', 'null', '\N', '')
  EMPTY_FIELD_AS_NULL = TRUE
  COMPRESSION = 'AUTO';

-- Pipe-delimited CSV (for legacy system integration)
CREATE OR REPLACE FILE FORMAT util_db.formats.csv_pipe
  TYPE = 'CSV'
  FIELD_DELIMITER = '|'
  RECORD_DELIMITER = '\n'
  SKIP_HEADER = 0
  ESCAPE = '\\'
  ESCAPE_UNENCLOSED_FIELD = '\\'
  TRIM_SPACE = TRUE;

-- Error-tolerant CSV format (for unstable data quality)
CREATE OR REPLACE FILE FORMAT util_db.formats.csv_tolerant
  TYPE = 'CSV'
  FIELD_DELIMITER = ','
  SKIP_HEADER = 1
  FIELD_OPTIONALLY_ENCLOSED_BY = '"'
  ERROR_ON_COLUMN_COUNT_MISMATCH = FALSE
  REPLACE_INVALID_CHARACTERS = TRUE;

Key CSV Options

OptionDefaultDescription
FIELD_DELIMITER,Field delimiter character
RECORD_DELIMITER\nRecord delimiter character
SKIP_HEADER0Number of header rows to skip
FIELD_OPTIONALLY_ENCLOSED_BYNONEField enclosure character (' or ")
NULL_IF\\NList of strings to interpret as NULL
ERROR_ON_COLUMN_COUNT_MISMATCHTRUEWhether to error on column count mismatch
ESCAPENONEEscape character inside enclosure characters
ENCODINGUTF-8File encoding (Shift_JIS, etc. can also be specified)

Creating a JSON File Format

-- Basic JSON File Format
CREATE OR REPLACE FILE FORMAT util_db.formats.json_standard
  TYPE = 'JSON'
  STRIP_OUTER_ARRAY = TRUE
  STRIP_NULL_VALUES = FALSE
  IGNORE_UTF8_ERRORS = FALSE
  COMPRESSION = 'AUTO';

-- Nested JSON (loaded into a VARIANT column)
CREATE OR REPLACE FILE FORMAT util_db.formats.json_nested
  TYPE = 'JSON'
  STRIP_OUTER_ARRAY = TRUE
  ALLOW_DUPLICATE = TRUE
  ENABLE_OCTAL = FALSE;

Key JSON Options

OptionDefaultDescription
STRIP_OUTER_ARRAYFALSEWhether to strip the outer array and treat each element as a separate row
STRIP_NULL_VALUESFALSEWhether to strip keys with NULL values
ALLOW_DUPLICATEFALSEWhether to allow duplicate keys
IGNORE_UTF8_ERRORSFALSEWhether to ignore invalid UTF-8 characters
DATE_FORMAT / TIME_FORMAT / TIMESTAMP_FORMATAUTOFormat used to interpret dates and times

Creating Parquet / Avro / ORC File Formats

-- Parquet File Format
CREATE OR REPLACE FILE FORMAT util_db.formats.parquet_standard
  TYPE = 'PARQUET'
  COMPRESSION = 'SNAPPY'
  BINARY_AS_TEXT = FALSE;

-- Avro File Format
CREATE OR REPLACE FILE FORMAT util_db.formats.avro_standard
  TYPE = 'AVRO'
  COMPRESSION = 'AUTO';

-- ORC File Format
CREATE OR REPLACE FILE FORMAT util_db.formats.orc_standard
  TYPE = 'ORC'
  TRIM_SPACE = FALSE;

File Format Comparison Table

CharacteristicCSVJSONParquetAvroORC
Data layoutRow-oriented textSemi-structured textColumnar binaryRow-oriented binaryColumnar binary
Schema infoNoneSelf-describingEmbeddedEmbeddedEmbedded
Compression efficiencyLow-MediumLow-MediumHighMediumHigh
Load speedFastModerateFastModerateModerate
Recommended useLegacy integrationAPI / IoT dataAnalytics workloadsKafka integrationMigration from Hive

File Format Usage Patterns with COPY INTO

-- Pattern 1: Reference a named File Format
COPY INTO raw_data.orders
FROM @landing_stage/orders/
FILE_FORMAT = util_db.formats.csv_standard
ON_ERROR = 'CONTINUE';

-- Pattern 2: Specify options inline
COPY INTO raw_data.events
FROM @landing_stage/events/
FILE_FORMAT = (TYPE = 'JSON' STRIP_OUTER_ARRAY = TRUE);

-- Pattern 3: Load from Parquet with auto schema detection
COPY INTO raw_data.metrics
FROM @landing_stage/metrics/
FILE_FORMAT = util_db.formats.parquet_standard
MATCH_BY_COLUMN_NAME = CASE_INSENSITIVE;

-- Unload: export from table to Parquet files
COPY INTO @export_stage/reports/
FROM analytics.monthly_report
FILE_FORMAT = util_db.formats.parquet_standard
HEADER = TRUE
OVERWRITE = TRUE;

Binding a File Format to a Stage

-- Specify the File Format when creating the stage
CREATE OR REPLACE STAGE csv_landing
  URL = 's3://my-bucket/csv/'
  STORAGE_INTEGRATION = s3_integration
  FILE_FORMAT = util_db.formats.csv_standard;

-- In this case, FILE_FORMAT is not required in COPY INTO
COPY INTO raw_data.orders FROM @csv_landing;

File Format Management Commands

-- List
SHOW FILE FORMATS IN SCHEMA util_db.formats;

-- Inspect the definition in detail
DESCRIBE FILE FORMAT util_db.formats.csv_standard;

-- Change an option
ALTER FILE FORMAT util_db.formats.csv_standard
  SET SKIP_HEADER = 2;

-- Drop
DROP FILE FORMAT util_db.formats.csv_standard;

Troubleshooting

ErrorCauseFix
Number of columns mismatchCSV column count does not match the table definitionSet ERROR_ON_COLUMN_COUNT_MISMATCH = FALSE, or fix the table definition
Invalid UTF-8 characterNon-UTF-8 files such as Shift_JISSpecify ENCODING = 'SHIFT_JIS', or use REPLACE_INVALID_CHARACTERS = TRUE
Failed to parse JSONJSON syntax error or outer arrayCheck the STRIP_OUTER_ARRAY = TRUE setting and validate the source file syntax
Conversion errorData type conversion failureExplicitly specify DATE_FORMAT / TIMESTAMP_FORMAT

Best Practices

  • Consolidate File Formats in a central management schema: manage them in a shared schema such as util_db.formats and GRANT the USAGE privilege to the roles that need it
  • Prefer Parquet for analytics workloads: columnar format with high compression efficiency, and it also supports schema evolution via MATCH_BY_COLUMN_NAME
  • Pre-validate with the VALIDATE function: before COPY INTO, identify problem rows with VALIDATION_MODE = 'RETURN_ERRORS' and only then load
  • Explicitly set NULL_IF and EMPTY_FIELD_AS_NULL: prevent data quality issues by making the treatment of empty strings versus NULL unambiguous

Check Your Understanding

Data Loading

問題 1

You are loading CSV files placed on S3 by an external system into Snowflake. You want the load to continue even when the file has more columns than the table definition. Which File Format option should you set?

  1. SKIP_HEADER = 1
  2. ON_ERROR = 'CONTINUE'
  3. ERROR_ON_COLUMN_COUNT_MISMATCH = FALSE
  4. REPLACE_INVALID_CHARACTERS = TRUE

正解: C

Setting ERROR_ON_COLUMN_COUNT_MISMATCH to FALSE prevents an error when the CSV column count does not match the table definition; extra columns are ignored and the load continues. SKIP_HEADER skips header rows, ON_ERROR controls how individual row errors are handled, and REPLACE_INVALID_CHARACTERS replaces invalid characters — none of which address column count mismatch.

Frequently Asked Questions

How many ways can you specify a File Format in COPY INTO?

There are 3 ways. (1) Reference a pre-created named File Format with FILE_FORMAT = my_format. (2) Specify options inline inside the COPY INTO statement, e.g. FILE_FORMAT = (TYPE = 'CSV' FIELD_DELIMITER = '|'). (3) Use a File Format bound to the stage. Creating a named File Format is recommended for reusability.

Can I specify STRIPE_COUNT or ROW_GROUP_SIZE for Parquet?

Snowflake's COPY INTO <location> (unload) supports COPY INTO ... FILE_FORMAT = (TYPE = 'PARQUET') for output, but Parquet-specific physical layout parameters such as ROW_GROUP_SIZE cannot be specified directly. Snowflake uses default optimal values on unload. If you need strict control over Parquet physical settings, consider unloading via an external tool such as Spark.

Can File Formats be referenced across schemas in COPY INTO?

Yes. By using a fully qualified name (database.schema.format_name), you can reference File Formats in other schemas or databases. The calling role needs USAGE privilege on the File Format. The operational best practice is to centralize shared File Formats in a common management schema (e.g., util_db.formats).

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Snowflake

Snowflake Certifications: All 11 Exams Explained (2026)

Every SnowPro certification — Associate, Core, Specialty, Ad...

Snowflake

Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)

All 11 SnowPro exams ranked by difficulty with study-time es...

Snowflake

Snowflake Study Guide: Fastest Pass Route by Exam (2026)

How to pass SnowPro certifications efficiently — official ma...

Snowflake

SnowPro Core (COF-C03): Complete Exam Guide (2026)

Pass the SnowPro Core exam — six domains, scope, sample ques...

Snowflake

SnowPro Associate Platform (SOL-C01): Complete Guide (2026)

The entry-level SnowPro Associate exam — scope, weighting, s...

Browse all Snowflake articles (103)
© 2026 NicheeLab All rights reserved.