Search code examples
hadoopapache-pig

Can 'NOT' be used in Foreach Generate statement?


Is there any way that prevents a column not to be generated using Foreach statement in Apache Pig? Example: part = FOREACH part GENERATE (NOT $3); in which a relation called 'part' has columns, say 5. I want all columns to be produced except '$3'. Is there any such way? Thanks in advance.


Solution

  • No, create a new relation say part_new and don't include that column in the foreach.

    part_new = FOREACH part GENERATE $0,$1,$2,$4;
    

    Alternatively

    part_new = FOREACH part GENERATE .. $2,$4;