How do I join 2 tables in PIG using 2 fields

0 votes

Hello, How do I join 2 tables in PIG using 2 fields.?

Syntax for 1 field :-> 

grunt> result = JOIN table1 BY col1, table2 BY col1;

How about if there are 2 fields(col1 & col2)  in table 1 which needs to join to 2 fields in table 2?

Dec 13, 2018 in Big Data Hadoop by digger
• 26,740 points
2,150 views

1 answer to this question.

0 votes

Here, we have two tables:

  • Tab1 having columns id, name and age
  • Tab2 having columns id, name and email

Using the below command to load data in pig,

tab1 = load ‘/mnt/home/edureka_425640/pig_join_1.txt’ using PigStorage(‘,’) as (id:int,name:chararray,age:int)

Dump tab1;

image

 

tab2 = load ‘/mnt/home/edureka_425640/pig_join_2.txt’ using PigStorage(‘,’) as (id:int,name:chararray,emal:chararrray)

Dump tab2;

image

Now, joining two tables on two columns

image

 

The below is the output:

image

Hope this helps you.

answered Dec 13, 2018 by Omkar
• 69,220 points

Related Questions In Big Data Hadoop

0 votes
1 answer

How can I get the respective Bitcoin value for an input in USD when using c#

Simply make call to server and parse ...READ MORE

answered Mar 25, 2018 in Big Data Hadoop by charlie_brown
• 7,720 points
1,075 views
0 votes
1 answer

How do I print hadoop properties in command line?

You can use the following command to get ...READ MORE

answered Apr 6, 2018 in Big Data Hadoop by kurt_cobain
• 9,350 points
1,843 views
0 votes
1 answer

How do I include all the Hadoop dependencies using Maven?

This is a dependency mismatch error. I ...READ MORE

answered Apr 10, 2018 in Big Data Hadoop by Shubham
• 13,490 points
6,543 views
0 votes
1 answer

How do I parse pdf file using MapReduce?

If you have your own custom InputFormat(WholeFileInputFormat). ...READ MORE

answered Apr 11, 2018 in Big Data Hadoop by Shubham
• 13,490 points
1,672 views
0 votes
1 answer

What do we exactly mean by “Hadoop” – the definition of Hadoop?

The official definition of Apache Hadoop given ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by Shubham
1,907 views
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
11,067 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
2,569 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
109,016 views
+1 vote
1 answer

How to count number of rows in alias in PIG?

COUNT is part of pig LOGS= LOAD 'log'; LOGS_GROUP= ...READ MORE

answered Oct 15, 2018 in Big Data Hadoop by Omkar
• 69,220 points
2,834 views
0 votes
1 answer

Hadoop: How to keep duplicates in Hive using collect_set()?

SELECT hash_id, COLLECT_LIST(num_of_cats) AS ...READ MORE

answered Nov 2, 2018 in Big Data Hadoop by Omkar
• 69,220 points
2,551 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP