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,550 points
127 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
• 67,660 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
75 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,260 points
264 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,310 points
796 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,310 points
230 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
227 views
0 votes
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
• 10,730 points
3,357 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
• 10,730 points
402 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
16,633 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
• 67,660 points
155 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
• 67,660 points
342 views