参考其他相关的question;通过以下配置,我可以将数据插入Redshift-
COPY "hits" FROM 's3://your-bucket/your_folder/'
CREDENTIALS 'aws_access_key_id=<AWS_ACCESS_KEY_ID>;aws_secret_access_key=<AWS_SECRET_ACCESS_KEY>'
FORMAT as JSON 's3://your-bucket/config/jsonpaths'
TIMEFORMAT as 'epochmillisecs';
它正在将'1528207694599'转换为'2018-06-05 14:08:14',但我期望的是'2018-06-05 14:08:14.599'。
有运气吗?提前致谢。
答案 0 :(得分:0)
似乎您在某个地方可能做错了什么,我想向您展示一个系统的步骤,以证明副本正确地填充了数据(包括毫秒)。
create table sales(
salesid integer not null,
category varchar(10),
update_at timestamp);
数据文件data.json的内容
[1,"Sports1","1528207694599"]
[2,"Sports2","1528207694456"]
映射文件json_path.json的内容
{
"jsonpaths": [
"$[0]",
"$[1]",
"$[2]"
]
}
然后复制命令,
COPY sales FROM 's3://s3-path/to/data/data.json' CREDENTIALS 'aws_access_key_id=**********;aws_secret_access_key=*******' FORMAT as JSON 's3://s3-path/to/mapping/json_path.json' TIMEFORMAT as 'epochmillisecs';
Output:
COPY sales FROM .............
INFO: Load into table 'sales' completed, 2 record(s) loaded successfully.
COPY;
$Select * from Sales;
salesid | category | update_at
---------+----------+-------------------------
2 | Sports2 | 2018-06-05 14:08:14.456
1 | Sports1 | 2018-06-05 14:08:14.599
(2 rows)
如您所见,update_at
的值包括毫秒。
希望对您有所帮助。