snowflake-cloud-data-platform

insert csv file into snowflake as variant not working


I am trying to copy csv data into snowflake table with only one column(variant). When I run copy into statement, my variant column is only displaying data from first column. I'm not sure what the problem is. Please help.

Create or replace table name( RAW variant )

COPY INTO db_name.table_name FROM (SELECT s.$1::VARIANT FROM @stage_name.csv s);


Solution

  • Assuming your .csv file consists of multiple, valid JSON, try using a file format of type JSON instead of .csv. See https://docs.snowflake.com/en/sql-reference/sql/create-file-format.html. Alternatively, use PARSE_JSON in your SELECT.