- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
PutSql With Date as argument
- Labels:
-
Apache NiFi
Created 02-21-2017 05:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I'm trying some examples with PutSQL processor. While doing trying the examples, gone through the PutSql.java code. When i checked the PutSql.java file , found that Date and Time data types always expects only Long.
Why is this restriction? Is it possible to make it to accept String also?
Created 02-21-2017 06:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems feasible to remove this restriction from Date and Time data types, as was done for Timestamps in NIFI-3430. Please feel free to write up a Jira case for this improvement.
In the meantime, if you are trying to do something like use the value '2017-02-21' in a field specified as Date/Time type, you could first change the value (possibly in an UpdateAttribute processor) using NiFi Expression Language's toDate() function. So if you have an attribute such as 'my.date.string' set to '2017-02-21' you could set an attribute 'my.date' equal to the following:
${my.date.string:format('yyyy-MM-dd')}
Created 02-21-2017 06:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems feasible to remove this restriction from Date and Time data types, as was done for Timestamps in NIFI-3430. Please feel free to write up a Jira case for this improvement.
In the meantime, if you are trying to do something like use the value '2017-02-21' in a field specified as Date/Time type, you could first change the value (possibly in an UpdateAttribute processor) using NiFi Expression Language's toDate() function. So if you have an attribute such as 'my.date.string' set to '2017-02-21' you could set an attribute 'my.date' equal to the following:
${my.date.string:format('yyyy-MM-dd')}
Created 02-21-2017 06:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I tried putting attribute " ${my.date.string:format('yyyy-MM-dd')} " in update attribute got some error in PUTSQL, its not updating the value into database.
please find the image of my dataflow in the attachment
Thanks
Created 02-22-2017 01:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Matt,
Thanks for suggestion and it worked 🙂 Tried like this:- ${my.date:toDate("yyyy-MM-dd"):toNumber()}
Thanks alot.
--Srikanth.
