Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

expression language for concatenating

Solved Go to solution

expression language for concatenating

Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: expression language for concatenating

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.

5 REPLIES 5

Re: expression language for concatenating

Contributor

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

Re: expression language for concatenating

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.

Re: expression language for concatenating

Contributor

@Matt Burgess Thanks for the prompt reply. I will try and confirm it Thanks again

Re: expression language for concatenating

Super Guru
@dhieru singh

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

Re: expression language for concatenating

Contributor

@Shu That worked thanks a lot appreciate it

Don't have an account?
Coming from Hortonworks? Activate your account here