- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
expression language for concatenating
- Labels:
-
Apache NiFi
Created ‎10-31-2017 01:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I am creating a new file name based on the time stamp and concatenate with random number but not able figure out the el expression for it
temp_${now():format("yyyy-MM-dd-HH-mm-ss"):join(random():mod(10):plus(1))},
however this expression is not valid EL expression
Thanks
Dheeru
Created ‎10-31-2017 01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The join() function, from the documentation, "may be used only in conjunction with the allAttributes
, allMatchingAttributes
, and allDelineatedValues
functions". I think you want the append() function:
temp_${now():format("yyyy-MM-dd-HH-mm-ss"):append(${random():mod(10):plus(1)})}
I tested this with my EL tester and it seems to work. However you might want to append a dash or underscore before the random digit, as the above expression will put the digit exactly after the number of seconds, unless that's what you want.
Created ‎10-31-2017 01:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried using this temp_${now():format("yyyy-MM-dd-HH-mm-ss"):join(${random():mod(10):plus(1)})}, this time it is a valid EL expressioon but not generating the random number still
Created ‎10-31-2017 01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The join() function, from the documentation, "may be used only in conjunction with the allAttributes
, allMatchingAttributes
, and allDelineatedValues
functions". I think you want the append() function:
temp_${now():format("yyyy-MM-dd-HH-mm-ss"):append(${random():mod(10):plus(1)})}
I tested this with my EL tester and it seems to work. However you might want to append a dash or underscore before the random digit, as the above expression will put the digit exactly after the number of seconds, unless that's what you want.
Created ‎10-31-2017 01:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Matt Burgess Thanks for the prompt reply. I will try and confirm it Thanks again
Created ‎10-31-2017 01:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Join aggregate function works on only attribute values and concatenate those values with the specific delimiter that means
if you are having abc attribute as value hello and xyz having world
${allAttributes("abc", "xyz"):join(" now ")} will result hello now world
i.e all the attribute values got concatenated with now.
If you want to add attribute then use the below EL will result.
temp_${now():format("yyyy-MM-dd-HH-mm-ss")}+${random():mod(10):plus(1)}
without join function will result
temp_2017-10-31-09-48-10+8
Created ‎10-31-2017 02:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Shu That worked thanks a lot appreciate it
