【发布时间】:2021-10-12 13:20:32
【问题描述】:
我有一个 csv,其中的行如下所示:
2021-08-20,2021-10-04,2021-10-04,148355456455712,Accountname,USD,"[{'action_type': 'add_to_cart', 'value': '266.63', '1d_click': '266.63', '7d_click': '266.63'}, {'action_type': 'initiate_checkout', 'value': '213.03', '1d_click': '213.03', '7d_click': '213.03'}, {'action_type': 'view_content', 'value': '762.75', '1d_click': '762.75', '7d_click': '762.75'}, {'action_type': 'omni_add_to_cart', 'value': '266.63', '1d_click': '266.63', '7d_click': '266.63'}, {'action_type': 'omni_initiated_checkout', 'value': '213.03', '1d_click': '213.03', '7d_click': '213.03'}, {'action_type': 'omni_view_content', 'value': '762.75', '1d_click': '762.75', '7d_click': '762.75'}, {'action_type': 'add_to_cart', 'value': '266.63', '1d_click': '266.63', '7d_click': '266.63'}, {'action_type': 'initiate_checkout', 'value': '213.03', '1d_click': '213.03', '7d_click': '213.03'}]"
我正在尝试将此 CSV 加载到具有以下架构的红移表中:
Columns Type Nullable Length Precision
date_start varchar true 256 256
date_stop varchar true 256 256
created_time varchar true 256 256
account_id int8 true 19 19
account_name varchar true 256 256
account_currency varchar true 256 256
action_values varchar true 256 256
我正在使用以下 DML 语句:
copy table_name
from 's3://bucket_name/subdirectory/filename.csv'
delimiter ','
ignoreheader 1
csv quote as '"'
dateformat 'auto'
timeformat 'auto'
access_key_id '...'
secret_access_key '...'
;
我得到这个错误:
Load into table 'table_name' failed. Check 'stl_load_errors' system table for details.
当我查看 stl_load_errors 表时,我看到的是:
query substring line value err_reason
93558 ... 2 2021-08-20 Invalid digit, Value '[', Pos 0, Type: Long
93558 ... 2 2021-10-04 Invalid digit, Value '[', Pos 0, Type: Long
93558 ... 2 2021-10-04 Invalid digit, Value '[', Pos 0, Type: Long
93558 ... 2 148355456455712 Invalid digit, Value '[', Pos 0, Type: Long
93558 ... 2 Accountname Invalid digit, Value '[', Pos 0, Type: Long
93558 ... 2 USD Invalid digit, Value '[', Pos 0, Type: Long
我只是不知道为什么它不起作用,但我想它与 json 字符串有关。我也不明白这个“类型:长”是从哪里来的。
我试图避免使用 Json 文件作为输入...
谁能帮忙?
【问题讨论】:
标签: sql json amazon-s3 amazon-redshift amazon-redshift-spectrum