0% found this document useful (0 votes)
2 views

Apache Pig

Apache Pig is a high-level platform for analyzing large datasets, primarily used with Hadoop, utilizing a language called Pig Latin for data manipulation. It simplifies MapReduce tasks, allowing programmers to write less code and handle both structured and unstructured data efficiently. Developed initially at Yahoo in 2006 and open-sourced in 2007, Apache Pig has become a key tool for data scientists in ad-hoc processing and quick prototyping.

Uploaded by

kajalyadav102703
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Apache Pig

Apache Pig is a high-level platform for analyzing large datasets, primarily used with Hadoop, utilizing a language called Pig Latin for data manipulation. It simplifies MapReduce tasks, allowing programmers to write less code and handle both structured and unstructured data efficiently. Developed initially at Yahoo in 2006 and open-sourced in 2007, Apache Pig has become a key tool for data scientists in ad-hoc processing and quick prototyping.

Uploaded by

kajalyadav102703
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Apache Pig - Overview https://www.tutorialspoint.com/apache_pig/apache_pig_overview.

htm

Apache Pig is an abstraction over MapReduce. It is a tool/platform which is used to


analyze larger sets of data representing them as data flows. Pig is generally used with
Hadoop; we can perform all the data manipulation operations in Hadoop using Apache
Pig.

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

Apache Pig comes with the following features −

Rich set of operators − It provides many operators to perform operations like


join, sort, filer, etc.

Ease of programming − Pig Latin is similar to SQL and it is easy to write a Pig
script if you are good at SQL.

Optimization opportunities − The tasks in Apache Pig optimize their


execution automatically, so the programmers need to focus only on semantics
of the language.

Extensibility − Using the existing operators, users can develop their own
functions to read, process, and write data.

UDF’s − Pig provides the facility to create User-defined Functions in other


programming languages such as Java and invoke or embed them in Pig Scripts.

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.

Apache Pig MapReduce

MapReduce is a data processing


Apache Pig is a data flow language.
paradigm.

It is a high level language. MapReduce is low level and rigid.

It is quite difficult in MapReduce to


Performing a Join operation in Apache Pig is
perform a Join operation between
pretty simple.
datasets.

Any novice programmer with a basic


Exposure to Java is must to work
knowledge of SQL can work conveniently
with MapReduce.
with Apache Pig.

Apache Pig uses multi-query approach, MapReduce will require almost 20


thereby reducing the length of the codes to a times more the number of lines to
great extent. perform the same task.

There is no need for compilation. On


MapReduce jobs have a long
execution, every Apache Pig operator is
compilation process.
converted internally into a MapReduce job.

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

Pig Latin is a procedural language. SQL is a declarative language.

In Apache Pig, schema is optional. We


can store data without designing a
Schema is mandatory in SQL.
schema (values are stored as $01, $02
etc.)

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.

In addition to above differences, Apache Pig Latin −

Allows splits in the pipeline.

Allows developers to store data anywhere in the pipeline.

Declares execution plans.

Provides operators to perform ETL (Extract, Transform, and Load) functions.

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 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.

Pig Latin is a data flow language. HiveQL is a query processing language.

Pig Latin is a procedural language and it


HiveQL is a declarative language.
fits in pipeline paradigm.

3 of 4 10/14/2024, 10:00 AM
Apache Pig - Overview https://www.tutorialspoint.com/apache_pig/apache_pig_overview.htm

Apache Pig can handle structured,


Hive is mostly for structured data.
unstructured, and semi-structured data.

Apache Pig is generally used by data scientists for performing tasks involving ad-hoc
processing and quick prototyping. Apache Pig is used −

To process huge data sources such as web logs.

To perform data processing for search platforms.

To process time sensitive data loads.

In 2006, Apache Pig was developed as a research project at Yahoo, especially to


create and execute MapReduce jobs on every dataset. In 2007, Apache Pig was open
sourced via Apache incubator. In 2008, the first release of Apache Pig came out. In
2010, Apache Pig graduated as an Apache top-level project.

4 of 4 10/14/2024, 10:00 AM

You might also like