Sub topic 14
Troubleshooting common load problems
This chapter assumes you can write a basic COPY INTO statement, know how PATTERN, FORMAT_OPTIONS and VALIDATE work, and understand that COPY INTO skips files it has already loaded. Here you will learn a repeatable way to diagnose a load that fails or does not behave as expected.
Start with the result row
Every COPY INTO run returns a result. A successful run reports how many rows were affected, how many were inserted, and how many were skipped. Check these numbers first, because they tell you which kind of problem you have.
- An error message means the load failed. Read the message and match it to a cause below.
- Zero rows inserted with no error means
COPY INTOfound nothing new to load. - A row count that is too high or too low points to file selection or duplicate loading.
Zero rows loaded
This is the most common surprise. Work through these causes in order.
- The files were already loaded.
COPY INTOtracks loaded files and skips them. This is expected behavior. If you really need a reload, useforce, but expect duplicates unless you clear the table first. - The path is wrong or empty. Run
LIST '/Volumes/main/sales/landing/orders/'to confirm that the files exist. - The pattern matches nothing.
PATTERNis a glob applied to the path under the source location. A pattern such as'2026-12-*.csv'matches nothing if the files are namedorders_2026-12-01.csv. - A file was changed after loading. A file with the same name is still treated as loaded, even if its contents changed.
Permission and access errors
If the error mentions access denied or an unknown location, check these:
- You need
READ VOLUMEon the volume, orREAD FILESon the external location. - You need
MODIFYandSELECTon the target table, plusUSE CATALOGandUSE SCHEMAon its parents. - The path must be inside a registered volume or external location. A raw cloud URL with no matching location fails.
Wrong or shifted columns
When values land in the wrong columns, or every column is null, the parser options usually do not match the files.
- With CSV, set
'header' = 'true'when the first row holds column names. Without it, the header becomes a data row. - Check
'delimiter'. A semicolon-separated file read with the default comma becomes one wide column. - Set
'multiLine' = 'true'if quoted fields contain line breaks. - Without
'inferSchema' = 'true', CSV columns load as strings. The load can fail later when the target expects numbers.
Type and schema errors
A cast failure such as a value that cannot convert to BIGINT means the data does not fit the target column. A message about an unknown or mismatched column means the file schema differs from the table.
- Use a
SELECTsource with explicitCASTexpressions to control types. - Add
COPY_OPTIONS ('mergeSchema' = 'true')if the files have gained new columns. - Remember that
mergeSchemaadds columns. It does not fix a type that conflicts with an existing column.
Preview before you commit
Use VALIDATE to reproduce a problem without writing data. It checks the first rows against the target table and returns them, so you can see parse errors and shifted columns safely.
COPY INTO main.sales.orders
FROM '/Volumes/main/sales/landing/orders/'
FILEFORMAT = CSV
VALIDATE 10 ROWS
FORMAT_OPTIONS ('header' = 'true', 'delimiter' = ';');Change one option at a time and run the validation again until the preview looks right. Then remove the VALIDATE line to load.
Duplicate rows
Duplicates almost always come from force = true, or from the same data arriving in files with different names. COPY INTO tracks file paths, not row contents. Deduplicate downstream with MERGE, or stop the sources from writing the same data twice.
Exercise
A scheduled COPY INTO job runs without error but reports zero rows inserted, even though a colleague says new files arrived. Name the first two checks you would make.
Show answer
First, run LIST on the source path to confirm the new files exist there. Second, check that PATTERN matches the new file names. Also confirm the new files do not reuse the names of files that were already loaded, because COPY INTO skips those.