Examples on Pig Commands | Big Data
22K views
Oct 24, 2024
Examples on Pig Commands
View Video Transcript
0:00
In this video, we are going to discuss examples on pick commands
0:05
So, at first, we are going to discuss 4-H and generate command
0:10
So, the 4-H operator is used to generate specified transformations based on the column data
0:17
So, the syntax of 4-H will be like this. So, variable name is equal to 4-H-table-name, generate, and required columns
0:26
So, variable name is equal to 4 each table name generate and required columns here
0:33
So to execute this command, we need to use the dump comment also
0:39
Next one is the filter command. We know that using filter we can see on the specific selected rows or the records
0:47
The filter operator is used to select the required tuples from the relation based on a certain
0:53
condition. So, the syntax will be like this. So, variable name is equal to filter table name by
0:59
the respective conditions. To execute this command, we need to use dump. Next one, we are going for
1:08
this order by command The order by operator is used to display the contents of a deletion in a short order based on one or more fields And the syntax of this will be variable name is equal to order table name by field ascending
1:27
or descending. So either I shall be using ASC or DESC and then semicolon
1:34
The ASC means the ascending order and DESC means that descending order
1:39
To execute this command, we need to use dump here. For the better understanding, let us go for one demonstration to show you that how these
1:47
commands can work in practice. Now in this video, we shall show you that how to use for each and generate command in our
1:56
ground shell. So the first query we are going to execute is that display the name and the city fields for
2:03
all rows. So that means I do not want to print name, major and city all the
2:09
the three attributes all the three fields I want to display only the name and the city
2:14
that means it is it is giving you a flavor of projection where you are selecting
2:18
some of the columns but not all the columns but all the rows will be coming
2:21
so display the name and the city fields for all rows so at first I shall go for this for gen so there is a variable name you can give some other name also so for gen is equal to for each
2:37
student generate city the order in which you are mentioning here in the same
2:46
order it will be coming so I shall go for this enter so for each student
2:51
generate city common name So now I shall go for say dump to see the content, dump for gen
3:05
So we are having five rows. You see all the five rows are coming, but the major is not coming
3:10
The department name is not coming. The subject is not coming. There is a major. The city is coming and the name is coming
3:16
You see the same command. So it is immaterial, whether you are typing this one all in the capital letters or not
3:23
So there is immaterial here. Intentionally I am changing this name the sequence that is the name and the city making this one name and city if I press enter then dump dump for gen so now the name is coming at the front and then cities after that so
3:58
names are coming and then the cities are coming for the all rows for the all
4:01
five rows now next we shall go for the filter comment so let us consider
4:06
one query display the student information where the city is Kolkata so how many how many rows are there with the Kolkata city two rows are
4:15
there Amit and Kushal okay so display the student information where the city is
4:20
Kolkata so now here I'm going for the selection operation okay so how to do
4:25
that one so I shall go for say Cole stood I can give other name also so that
4:30
is not an issue so Cole stood is equal to filter I can write this filter in
4:35
the capital letters I'm not going to show you that one because I've shown that one earlier in case of forage and generate so by city double equal to within
4:46
single code Kolkata you see in the table we're having the Kolkata K capital so
4:52
called stute is equal to filter student by city is equal to is equal to Kolkata so
4:58
I have executed this one now
#Computer Education
#Distance Learning
#Educational Software
#Java (Programming Language)