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.).
-- 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;| Option | Default | Description |
|---|---|---|
| FIELD_DELIMITER | , | Field delimiter character |
| RECORD_DELIMITER | \n | Record delimiter character |
| SKIP_HEADER | 0 | Number of header rows to skip |
| FIELD_OPTIONALLY_ENCLOSED_BY | NONE | Field enclosure character (' or ") |
| NULL_IF | \\N | List of strings to interpret as NULL |
| ERROR_ON_COLUMN_COUNT_MISMATCH | TRUE | Whether to error on column count mismatch |
| ESCAPE | NONE | Escape character inside enclosure characters |
| ENCODING | UTF-8 | File encoding (Shift_JIS, etc. can also be specified) |
-- 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;| Option | Default | Description |
|---|---|---|
| STRIP_OUTER_ARRAY | FALSE | Whether to strip the outer array and treat each element as a separate row |
| STRIP_NULL_VALUES | FALSE | Whether to strip keys with NULL values |
| ALLOW_DUPLICATE | FALSE | Whether to allow duplicate keys |
| IGNORE_UTF8_ERRORS | FALSE | Whether to ignore invalid UTF-8 characters |
| DATE_FORMAT / TIME_FORMAT / TIMESTAMP_FORMAT | AUTO | Format used to interpret dates and times |
-- 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;| Characteristic | CSV | JSON | Parquet | Avro | ORC |
|---|---|---|---|---|---|
| Data layout | Row-oriented text | Semi-structured text | Columnar binary | Row-oriented binary | Columnar binary |
| Schema info | None | Self-describing | Embedded | Embedded | Embedded |
| Compression efficiency | Low-Medium | Low-Medium | High | Medium | High |
| Load speed | Fast | Moderate | Fast | Moderate | Moderate |
| Recommended use | Legacy integration | API / IoT data | Analytics workloads | Kafka integration | Migration from Hive |
-- 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;-- 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;-- 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;| Error | Cause | Fix |
|---|---|---|
| Number of columns mismatch | CSV column count does not match the table definition | Set ERROR_ON_COLUMN_COUNT_MISMATCH = FALSE, or fix the table definition |
| Invalid UTF-8 character | Non-UTF-8 files such as Shift_JIS | Specify ENCODING = 'SHIFT_JIS', or use REPLACE_INVALID_CHARACTERS = TRUE |
| Failed to parse JSON | JSON syntax error or outer array | Check the STRIP_OUTER_ARRAY = TRUE setting and validate the source file syntax |
| Conversion error | Data type conversion failure | Explicitly specify DATE_FORMAT / TIMESTAMP_FORMAT |
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?
正解: 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.
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).
Practice with certification-focused question sets
無料で問題を解いてみる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.
Snowflake Certifications: All 11 Exams Explained (2026)
Every SnowPro certification — Associate, Core, Specialty, Ad...
Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)
All 11 SnowPro exams ranked by difficulty with study-time es...
Snowflake Study Guide: Fastest Pass Route by Exam (2026)
How to pass SnowPro certifications efficiently — official ma...
SnowPro Core (COF-C03): Complete Exam Guide (2026)
Pass the SnowPro Core exam — six domains, scope, sample ques...
SnowPro Associate Platform (SOL-C01): Complete Guide (2026)
The entry-level SnowPro Associate exam — scope, weighting, s...