bfmcneill
bfmcneill

Reputation: 127

SnowSQL JSONL vs JSON

Is it possible to load JSONL using the the JSON file format type='JSON'? Or would I need to convert the JSONL to JSON?

As it stands right now I am able to stage the data but when I try to copy into a table the query errors out stating there is a data error.

Upvotes: 1

Views: 612

Answers (1)

Gokhan Atil
Gokhan Atil

Reputation: 10059

You can use CSV format to read each line of JSONL (with a non-common delimiter), then parse them using PARSE_JSON.

Sample test.jsonl:

{ "id":1, "name":"Gokhan"}
{ "id":2, "name":"Jack"}
{ "id":3, "name":"Joe"}

Sample file format object:

create file format jsonl type=CSV field_delimiter = '*xyz*';

Reading using parse_json:

select parse_json($1) js, js:id, js:name from @my_stage (file_format=>jsonl);

Upvotes: 2

Related Questions