gpt4 book ai didi

snowflake-cloud-data-platform - 如何解决错误 "Field delimiter ' ,' found while expecting record delimiter '\n'"while loading json data to the stage

转载 作者:行者123 更新时间:2023-12-05 01:54:19 25 4
gpt4 key购买 nike

我正在尝试使用“COPY INTO”命令将数据从 s3 加载到雪花

以下是我创建舞台并将文件从舞台加载到 Snowflake 所遵循的步骤

JSON 文件

{
"Name":"Umesh",
"Desigantion":"Product Manager",
"Location":"United Kingdom"
}
create or replace stage emp_json_stage
url='s3://mybucket/emp.json'
credentials=(aws_key_id='my id' aws_secret_key='my key');

# create the table with variant
CREATE TABLE emp_json_raw (
json_data_raw VARIANT
);

#load data from stage to snowflake

COPY INTO emp_json_raw from @emp_json_stage;

我遇到了错误

Field delimiter ',' found while expecting record delimiter '\n' File'emp.json', line 2, character 18 Row 2, column"emp_json_raw"["JSON_DATA_RAW":1]

我正在使用一个简单的 JSON 文件,但我不明白这个错误。

是什么原因造成的,我该如何解决?

最佳答案

文件格式未指定,默认为 CSV 格式,因此出现错误。

试试这个:

COPY INTO emp_json_raw 
from @emp_json_stage
file_format=(TYPE=JSON);

除了 TYPE 之外,还有其他选项可以用 file_format 指定。请参阅此处的文档:https://docs.snowflake.com/en/sql-reference/sql/copy-into-table.html#type-json

关于snowflake-cloud-data-platform - 如何解决错误 "Field delimiter ' ,' found while expecting record delimiter '\n'"while loading json data to the stage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70719467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com