簡體   English   中英

來自 json 列表的雪花外部表

[英]snowflake external table from a list of jsons

在我的 s3 存儲桶中有一個 file.json,它包含一個 json 列表,例如,當我下載它並使用 python json load 解析它時,我得到一個列表:

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

將其加載到外部表中工作:

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

但是我沒有得到一個包含 2 行的表,而是得到一個包含列表的行,有什么想法嗎?

如果該值作為數組提供,則可以使用strip_outer_array

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

此外,如果預先知道 json 鍵,它們可以直接在外部表的定義中作為列公開:

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM