简体   繁体   中英

snowflake external table from a list of jsons

got a file.json in my s3 bucket, it contains a list of jsons, for instance when I download it and parse it with python json load I get a list:

[{'k': 'calendar#event'}, {'k': 'calendar#event'}]\

loading it into an external table works:

create external table if not exists TEST_111
with location = @TESt111
auto_refresh = true
file_format = (type = json);

but instead of getting a table with 2 rows, I get one row with a list in it, any ideas?

If the value is provided as array then strip_outer_array could be used:

create external table if not exists TEST_111
with location = @TESt111
auto_refresh = true
file_format = (type = json, STRIP_OUTER_ARRAY=TRUE);

Additionally if the json keys are known in advance, they could be exposed as columns directly in external table's definition:

create external table if not exists TEST_111
(
    filename    TEXT  metadata$filename
   ,k           TEXT  AS (value:"k"::TEXT)
)
with location = @TESt111
auto_refresh = true
file_format = (type = json, STRIP_OUTER_ARRAY=TRUE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM