Pig equivalent of SQL GREATEST / LEAST?

前端 未结 1 860
傲寒
傲寒 2021-01-14 09:34

I\'m trying to find the Pig equivalent of the SQL functions GREATEST and LEAST. These functions are the scalar equivalent of the aggregate SQL functions MAX and

1条回答
  •  醉梦人生
    2021-01-14 10:25

    It turns out that there are "inline" bag-based approaches that work:

    x = LOAD 'file:///a/b/c.csv' USING PigStorage() AS (a: int, b: int, c: int);
    y = FOREACH x GENERATE a AS a: int, b AS b: int, c AS c: int, MAX(TOBAG(a, b, c)) AS g: int;
    

    0 讨论(0)
提交回复
热议问题