• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pig script - append previous line to all corresponding matched rows

 
raghavendra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log file looks as below:

.....
.......
com/org/poc/applicationModule/UserImpl.java
Error(11,66): package com.org.poc.applicationModule does not exist
Error(12,53): package com.org.poc.service.view does not exist
com/org/poc/applicationModule/RowImpl.java
Error(5,60): package com.org.poc.Entity.core does not exist
Error(6,71): package com.org.poc.publicEntity does not exist
...


log = load '$input' using PigStorage('\n') as (line:chararray);
errorLogs = FILTER log by (line matches '.*Error\\(.*');

corresponding file path appears in the previous line of Error rows, able to retrieve all error rows using matches keyword but final output need to generate as below by appending file path to each Error row.

Error(11,66): package com.org.poc.applicationModule does not exist : com/org/poc/applicationModule/UserImpl.java
Error(12,53): package com.org.poc.service.view does not exist : com/org/poc/applicationModule/UserImpl.java
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic