Hi I have the following Pig code:
leafNodes = FOREACH records GENERATE
'buckets' AS bucket_url,
MultiConcat(localziedName, ' in ', localizedLocation) AS title,
ToJSONString(
'url', url,
'title', MultiConcat(localziedName, ' in ', localizedLocation)
) AS link_json;
The same MultiConcat(localziedName, ' in ', localizedLocation)
call is made twice. So, is there a way to use variable or something like that to reduce the call to once?
I found a way to do it. Basically, just create a variable right before the GENERATE statement. Here is the code:
leafNodes = FOREACH records {
title = MultiConcat(localziedName, ' in ', localizedLocation);
GENERATE
'buckets' AS bucket_url,
title,
ToJSONString(
'url', url,
'title', title
) AS link_json;
}