将雪花表数据以PARQUET格式卸载到S3 [英] Unload Snowflake table data into S3 in Parquet format
本文介绍了将雪花表数据以PARQUET格式卸载到S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从Snowflake表加载到S3存储桶后,我可以在列下看到所有值为Null。
下面是我使用的代码。
create or replace stage STG_LOAD
url='s3://bucket/foler'
credentials=(aws_key_id='xxxx',aws_secret_key='xxxx')
file_format = (type = PARQUET);
copy into STG_LOAD from
(select OBJECT_CONSTRUCT(country_cd,source)
from table_1
file_format = (type='parquet')
header='true';
如果我遗漏了什么,请告诉我。
推荐答案
看到空值是正常的。这是意料之中的行为。您的SELECT会生成一个空对象,因此会将其写入为空值:
create or replace table table_1
( country_cd varchar, source varchar ) as
select * from values
('US','Jack'),
('UK','Joe'),
('NL','Jim'),
('EU', null);
select OBJECT_CONSTRUCT(country_cd,source) output
from table_1
+------------------+
| OUTPUT |
+------------------+
| { "US": "Jack" } |
| { "UK": "Joe" } |
| { "NL": "Jim" } |
| {} |
+------------------+
如果您不想写入空值,可以在您的选择中对其进行筛选:
copy into @STG_LOAD from
(select OBJECT_CONSTRUCT(country_cd,source ) output
from table_1
where output != OBJECT_CONSTRUCT() ) -- no empty objects
file_format = (type=parquet)
overwrite = true;
这篇关于将雪花表数据以PARQUET格式卸载到S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文