apache pig - Pig - Convert rows into multiple columns -


can convert input rows multiple columns terminated three.*

 image

here 1 naive solution.

grouping every 3 rows using rank , group, , filter each of 3 conditions.

my pig script

a = load '/path_to_data/data' (c1 : chararray); b = rank a; c = foreach b generate (rank_a+2)/3 id, c1;  d = foreach (group c id) {         1 = filter c c1 matches 'one:.*';          2 = filter c c1 matches 'two:.*';          3 = filter c c1 matches 'three:.*';          generate              group id             , flatten(one.c1) c1_one             , flatten(two.c1) c1_two             , flatten(three.c1) c1_three         ;     };  dump d; 

my result

(1,one:"a",two:"2",three:"last") (2,one:"b",two:"1",three:"first") 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -