您好我有以下猪码:
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;
同一次MultiConcat(localziedName, ' in ', localizedLocation)
来电两次。那么,有没有办法使用变量或类似的东西来减少一次调用?
答案 0 :(得分:1)
我找到了办法。基本上,只需在GENERATE语句之前创建一个变量。这是代码:
leafNodes = FOREACH records {
title = MultiConcat(localziedName, ' in ', localizedLocation);
GENERATE
'buckets' AS bucket_url,
title,
ToJSONString(
'url', url,
'title', title
) AS link_json;
}