Reputation: 1
copy into command executes successfully but no rows are loaded. What am I doing wrong here?
COPY INTO BIKE_SHARE FROM @~/C:\temp\snowflakedata\202109-divvy-tripdata.csv file_format = (type = csv, skip_header=1) validation_mode='RETURN_1_rows';
Upvotes: 0
Views: 1055
Reputation: 495
The copy command is being run using VALIDATION_MODE
. This copy option allows the copy command to validate the files and not load them. So using this option, one can see the errors in the file but the data is not loaded into the target table.
VALIDATION_MODE = RETURN_n_ROWS | RETURN_ERRORS | RETURN_ALL_ERRORS String (constant) that instructs the COPY command to validate the data files instead of loading them into the specified table; i.e. the
COPY command tests the files for errors but does not load them. The command validates the data to be loaded and returns results based on the validation option specified
https://docs.snowflake.com/en/sql-reference/sql/copy-into-table.html
Upvotes: 0
Reputation: 1685
The command has been executed successfully because in Snowflake "@~" is a user stage location that exists by default. Your command tries to load the file from the default user stage and if the file is not there it is executed but no rows are loaded.
Probably you are missing the step to upload your file on a stage. You should do this first using, e.g. SnowSQL client to execute the PUT command:
put file://C:\temp\snowflakedata\202109-divvy-tripdata.csv@~ auto_compress=true;
Then if you table definition and the file are OK you should execute your copy command and get the rows loaded.
Upvotes: 1