Apache Pig
Apache Pig
htm
To write data analysis programs, Pig provides a high-level language known as Pig
Latin. This language provides various operators using which programmers can develop
their own functions for reading, writing, and processing data.
To analyze data using Apache Pig, programmers need to write scripts using Pig Latin
language. All these scripts are internally converted to Map and Reduce tasks. Apache
Pig has a component known as Pig Engine that accepts the Pig Latin scripts as input
and converts those scripts into MapReduce jobs.
Programmers who are not so good at Java normally used to struggle working with
Hadoop, especially while performing any MapReduce tasks. Apache Pig is a boon for all
such programmers.
Using Pig Latin, programmers can perform MapReduce tasks easily without
having to type complex codes in Java.
Apache Pig uses multi-query approach, thereby reducing the length of codes.
For example, an operation that would require you to type 200 lines of code
(LoC) in Java can be easily done by typing as less as just 10 LoC in Apache Pig.
Ultimately Apache Pig reduces the development time by almost 16 times.
Pig Latin is SQL-like language and it is easy to learn Apache Pig when you are
familiar with SQL.
Apache Pig provides many built-in operators to support data operations like
joins, filters, ordering, etc. In addition, it also provides nested data types like
tuples, bags, and maps that are missing from MapReduce.
Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.
1 of 4 10/14/2024, 10:00 AM
Apache Pig - Overview https://www.tutorialspoint.com/apache_pig/apache_pig_overview.htm
Ease of programming − Pig Latin is similar to SQL and it is easy to write a Pig
script if you are good at SQL.
Extensibility − Using the existing operators, users can develop their own
functions to read, process, and write data.
Handles all kinds of data − Apache Pig analyzes all kinds of data, both
structured as well as unstructured. It stores the results in HDFS.
Listed below are the major differences between Apache Pig and MapReduce.
2 of 4 10/14/2024, 10:00 AM
Apache Pig - Overview https://www.tutorialspoint.com/apache_pig/apache_pig_overview.htm
Listed below are the major differences between Apache Pig and SQL.
Pig SQL
The data model in Apache Pig is nested The data model used in SQL is flat
relational. relational.
Apache Pig provides limited opportunity There is more opportunity for query
for Query optimization. optimization in SQL.
Both Apache Pig and Hive are used to create MapReduce jobs. And in some cases, Hive
operates on HDFS in a similar way Apache Pig does. In the following table, we have
listed a few significant points that set Apache Pig apart from Hive.
Apache Pig uses a language called Pig Hive uses a language called HiveQL. It
Latin. It was originally created at Yahoo. was originally created at Facebook.
3 of 4 10/14/2024, 10:00 AM
Apache Pig - Overview https://www.tutorialspoint.com/apache_pig/apache_pig_overview.htm
Apache Pig is generally used by data scientists for performing tasks involving ad-hoc
processing and quick prototyping. Apache Pig is used −
4 of 4 10/14/2024, 10:00 AM