DEFINE GenerateRelationFromString(string) RETURNS relation { temp = LOAD 'somefile'; tempLimit1 = LIMIT temp 1; $relation = FOREACH tempLimit1 GENERATE FLATTEN(TOKENIZE('$string', ',')); };
using:
fourRows = GenerateRelationFromString('1,2,3,4'); myConstantRelation = FOREACH fourRows GENERATE ( CASE $0 WHEN '1' THEN (1, 'Ivan') WHEN '2' THEN (2, 'Boris') WHEN '3' THEN (3, 'Vladimir') WHEN '4' THEN (4, 'Olga') END ) as myTuple;
This is certainly a hack, and the correct way, in my opinion, would be to implement StringLoader (), which would work as follows:
fourRows = LOAD '1,2,3,4' USING StringLoader(',');
The argument commonly used for file location will only be used as an input to the litral line.
source share