我正试图将数据从UTF-8编码的CSV文件插入到Redshift数据库中,但当试图将时间戳插入到具有timestamp
数据类型的列中时,我得到了错误。
下面是一个CSV示例:
employeeId,employeeDept,employeeName,shiftStartTime,shiftEndTime,onPremises
KL214691,John Smith,operations,2023-01-17 09:01:34,2023-01-17 16:52:41,1
KL214692,Samantha Kennedy,operations,2023-01-17 08:31:54,2023-01-17 16:09:10,1
下面是一个示例表DDL:
create table historical_metrics_agent_status_time_on_status
(
employeeid varchar(10),
employeename varchar(100),
employeedept varchar(50),
shiftstarttime timestamp encode az64,
shiftendtime timestamp encode az64,
onpremises boolean,
importdatetime timestamp encode az64
)
sortkey (employeeid);
错误信息显示在shiftstarttime
列的第4位上有一个无效的数字-
,其原始字段值为2023-01-17 09:01:34
。看起来它没有正确地从CSV文件中读取时间戳。我在CSV中缺少什么吗?
检查stl_load_errors,查找失败的确切行。我的猜测是,其中一个VARCHAR列中有一个逗号(,),并且偏离了CSV到表列的对齐。例如,如果其中一个名字输入为" Smith, Joe "。