Breaking News
Loading...

Union and Split



Union:
Pig Latin provides union to put two data sets together by concatenating them instead of
joining them. Unlike union in SQL, Pig does not require that both inputs share the same schema.
If both do share the same schema, the output of the union will have that schema. If one schema can be produced from another by a set of implicit casts, the union will have that resulting schema. If neither of these conditions hold, the output will have no schema (that is,different records will have different fields).


Example4:  Union and Split
Inputs:
File A:                                          File B
(0,1,2)                                                             (0,5,2)
(1,3,4)                                                             (1,7,8)

Problem: Group all rows starting with 0 and starting with 1 seperately
Code:



DUMP d;
(0,1,2)
(0,5,2)
DUMP e;
(1,3,4)
(1,7,8)

- See more at: http://labstrikes.blogspot.in/2012/08/adsense-middle-blog-post.html#sthash.gQgSkqx8.dpuf
 
Toggle Footer