Asking a question, there is a problem while sending e-commerce information to BigQuery in a csv file. In csv, the value of the ORDER_DATE
column should go into the yyyy-MM-dd HH:mm:ss
format in the DATETIME
type column in the BigQuery, tried to find some references on Google.
Replacement Value Strategy was selected to Literal Value, and/ORDER_DATE
was added as a new field. The value is as follows:
${field.value:toDate('yyyyMMddhhmmss','GMT'):format('yyyy-MM-dd hh:mm:ss', 'GMT')}
Found a new reference, that the NiFi expression was wrong, so I did another way:
${field.value:equals('0'):ifElse('', ${field.value:replace(${field.value},${field.value:toDate('yyyyMMddHHmmss'):format('yyyy-MM-dd HH:mm:ss'):toString()})})}
Someone asked me to open the log, checked and it's as follows:
java.lang.NumberFormatException: For input string: "2022-01-08 15:22:17"
Any ideas? Thank you :)
Solved the problem using UpdateRecord
without adding to upstream ValidateCSV
.
In controller services, CSVReader
and CSVRecordSetWriter
were modified as follows:
Schema Access Strategy
of processor CSVReader
to User String Fields From Header
CSVRecordSetWriter
Here are the test results:
In GenerateFlowFile
, the following text to change to format yyyyMMddHmmss
was made into csv
CSVRecordSetWriter
left the default setting and set CSVReader
as follows
After completing the above setting, the value may be converted without an error
Searched to see the file in the error log and found the cause. It seemed to be inferred as type string, but it was type float, resulting in the above error.
Thank you for your comments. @VikramsinhShinde @Sdairs