Snowflake:当我使用复制命令将 json 文件框架为输出时,Object_construct 留下空值

Sun*_*dar 1 snowflake-schema snowflake-cloud-data-platform

我使用下面的 Snowflake 复制命令返回一个内容为 json 的文件

 copy into @elasticsearch/product/sf_index 
 from (select object_construct('id',id, alpha,'alpha')from table limit 1)  
 file_format = (type = json, COMPRESSION=NONE), overwrite=TRUE, single = TRUE, max_file_size=5368709120;
Run Code Online (Sandbox Code Playgroud)

数据为 id alpha 1 null

输出文件是

{
   "id" :1
}
Run Code Online (Sandbox Code Playgroud)

但我需要有空值

{
   "id" :  1,
   "alpha" : null
}
Run Code Online (Sandbox Code Playgroud)

小智 5

您可以使用该功能OBJECT_CONSTRUCT_KEEP_NULL

文档:https ://docs.snowflake.com/en/sql-reference/functions/object_construct_keep_null.html

例子:

select OBJECT_CONSTRUCT_KEEP_NULL('id',id, alpha,'alpha')
Run Code Online (Sandbox Code Playgroud)