Nifi PutSQL Timestamp/Datetime error cannot be con

2019-03-05 19:12发布

问题:

I tried the solution suggested to remove the timestamp format conversion error by using "UpdateAttribute" processor i.e. ConvertJSONtoSQL-> UpdateAttribute--> PutSQL

In UpdateAttribute I used

Property               Value
---------------        ------------------------
sql.args.4.value ->    ${sql.args.4.original:format("yyyy-MM-dd HH:mm:ss")}

Log:

The value of the sql.args.4.value is '', which cannot be converted to a timestamp at org.apache.nifi.processors.standard.PutSQL.setParameters(PutSQL.java:690) at

Without the use of UpdateAttribute I also tried direct ConvertJSONtoSQL-> PutSQL . Log showed the same error with datetime value in quote 'Aug 14 2017 10:17:00 EDT' i.e. when we use UpdateAttribute, it just removes the value and put empty quotes but the error is not resolved.

Note: MySQL table has datetime datatype for those columns not sure why it errors out by trying to convert to TimeStamp. I also tried Timestamp datatype in source and target table on localhost, no luck!

回答1:

Funny enough! I found the answer to my question . Please use sql.args.n.value -> ${sql.args.n.value:format("yyyy-MM-dd HH:mm:ss.SSS")}. Worked for me!