Can someone explain to me the difference between inner bag and outer bag with example? Thanks in advance
Jul 16, 2019 2,371 views

## 1 answer to this question.

Outer Bag:

An outer bag is nothing but a relation. In the below example, A is a relation or bag of tuples. You can think of this bag as an outer bag.

```A = LOAD 'data' as (f1:int, f2:int, f3:int);
DUMP A;

(1,2,3)
(4,2,1)
(8,3,4)
(4,3,3)
```

Inner bag:

An inner bag is a relation inside any other bag.

Example:

Now, suppose we group relation A by the first field to form relation X.

In this example, X is a relation or bag of tuples. The tuples in relation X have two fields. The first field is type int. The second field is type bag; you can think of this bag as an inner bag.

```X = GROUP A BY f1;
DUMP X;
(1,{(1,2,3)})
(4,{(4,2,1),(4,3,3)})
(8,{(8,3,4)})
```
answered Jul 16, 2019 by Firoz

## What do you understand by an inner bag and outer bag in Pig?

Outer bag or relation is nothing but ...READ MORE

## What is difference between pig and Mapreduce?

Hey, In MapReduce need to writ entire logic ...READ MORE

## Difference between Pig and Hive? Why have both? [closed]

The hive was designed to appeal to ...READ MORE

## Can we use Apache Sqoop and Hive both together? What is the difference between the two?

Yes, you can. In fact many people ...READ MORE

+1 vote

## Hadoop Mapreduce word count Program

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

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

–1 vote