[Solved-1 Solution] How to Drop single column in Pig ?



Problem :

How to drop single column in Pig ?

Solution 1:

  • We can easily drop the single column by using the column name or column name.
  • Make sure that we should know the particular column name or number that we want to drop

Drop column by number

  • If we want to drop column number 5
  • We can use the below code
D = FOREACH C GENERATE .. $4, $6 .. ;

Drop column by name

  • If we want to drop a column by name, it does not appear possible by only knowing the name of the column that we want to drop. However, it is possible if we know the names of the columns directly before and after this column.
  • If we want to drop the column(s) between colBeforeMyCol and colAfterMyCol,

Example:

aliasAfter = FOREACH aliasBefore GENERATE 
             .. colBeforeMyCol, colAfterMyCol ..;

Related Searches to How to Drop single column in Pig ?