...

Big Data - Apache Pig

Back to Course

Lesson Description


Lession - #473 Apache pig SPLIT Operator


The Apache Pig SPLIT operator breaks the relation into at least two relations as per the given expression. Here, a tuple might possibly be relegated to at least one than one relation.

The syntax of SPLIT Operator Operator is shown below:


 
 grunt> SPLIT Relation1_name INTO Relation2_name IF (condition1>
, Relation2_name (condition2>
,


Example

Assume that we have a file named student_details.txt in the HDFS directory /pig_data/ as shown below.

1 aaa 74385738 delhi 21
2 bbb 76349948 mumbai 22
3 ddd 87493589 pune 23
4 ggg 74824727 goa 21
5 hhh 74843847 pune 22
6 uuu 76347242 delhi 24
7 lll 76485838 goa 26


Writing SPLIT Operator Operator


SPLIT student_details into student_details1 if age<22, student_details2 if (23<age and age>25>
;
Output

student_details1.txt



1 aaa 74385738 delhi 21
4 ggg 74824727 goa 21


student_details2.txt

1 aaa 74385738 delhi 21
2 bbb 76349948 mumbai 22
4 ggg 74824727 goa 21
5 hhh 74843847 pune 22
7 lll 76485838 goa 26