将 JSON 数据从 Snowflake 复制到 S3
我正在尝试将数据(变体数据类型 - JSON)从 Snowflake 复制到 S3。我正在使用以下命令:
copy into @STG_SF_S3_DEV_JJC/sample_file1.json
from (select distinct RECORD_CONTENT from MYTABLE where LOAD_DT_TS >= '2022-02-09 00:00:00')
FILE_FORMAT = (TYPE=JSON,COMPRESSION = NONE)
SINGLE=true
header=true
OVERWRITE = TRUE;
正在复制数据。我正在使用 STORAGE_INTEGRATION 过程 &创建 STAGE 表。 我的问题是:
- 对于上面的查询,我得到 23 行,我想将这 23 行作为 23 个单独的文件(JSON 文件)加载到 S3 中。如何实现这一目标?
- 每条记录都有不同的 LOAD_DT_TS,因此对于每 23 个文件,我需要给出不同的名称。我的意思是,文件名应该以 LOAD_DT_TS 结尾。如何实现这一目标?
- MYTABLE 在上面的查询(COPY 命令)中,我有 4 列。有没有可能将所有 4 列加载到单个 JSON 文件中?
请分享您的想法。
I am trying to COPY data (Variant data type - JSON) from Snowflake to S3. I am using below command:
copy into @STG_SF_S3_DEV_JJC/sample_file1.json
from (select distinct RECORD_CONTENT from MYTABLE where LOAD_DT_TS >= '2022-02-09 00:00:00')
FILE_FORMAT = (TYPE=JSON,COMPRESSION = NONE)
SINGLE=true
header=true
OVERWRITE = TRUE;
The data is getting copied. I am using STORAGE_INTEGRATION process & creating STAGE table.
My question is:
- For above query, I am getting 23 rows and I want to load these 23 rows as 23 separate files (JSON files) in S3. How to achieve this?
- Each record has different LOAD_DT_TS and so for each 23 files, I need to give different names. I mean, the file name should end with LOAD_DT_TS. How to achieve this?
- MYTABLE in above query (COPY command), I have 4 columns. Is there any possible way to load all the 4 columns into a single JSON file?
Please share your thoughts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅下文(涵盖第 1 点和第 2 点)。
Please refer below (it covers point #1 and 2).
这适用于输入带引号放置的谓词值 -
This works for input a predicate value with quotes placement -
SINGLE=true - 此选项将完整的 SQL 输出发送到单个文件,如果删除此选项,则会将输出发送到单独的文件。
SINGLE=true - This option send the full SQL output to single file, if you remove this it will send the output to separate files.