简体   繁体   中英

Error when inserting timestamp data from CSV into a Redshift table column which is of timestamp data type

I am trying to insert data from an UTF-8 encoded CSV file into Redshift database but I get the error when attempting to insert timestamp into a column which has timestamp data type.

Here's a sample 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

Here's a sample table 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);

The error message shows that there's an invalid digit - on position 4 in column shiftstarttime which has raw field value 2023-01-17 09:01:34 . It looks like it's not reading timestamp from CSV file properly. Is there something I'm missing in CSV?

Check stl_load_errors for the exact row that is failing. My guess is that one of the VARCHAR columns has a comma (,) in it and is throwing off the alignment of the CSV to table columns. Like if one of the names is entered as “Smith, Joe”.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM