The explain operator is used to display the logical, physical, and MapReduce execution plans of a relation.
One of Pig’s goals is to allow you to think in terms of data flow instead of MapReduce. But sometimes you need to peek into the barn and see how Pig is compiling your script into MapReduce jobs.
Pig provides explain for this. explain is particularly helpful when you are trying to optimize your scripts or debug errors.
It was written so that Pig developers could examine how Pig handled various scripts, thus its output is not the most user-friendly.
But with some effort, explain can help you write better Pig Latin.
Syntax:
The syntax of the explain operator is
Usage:
Use the EXPLAIN operator to review the logical, physical, and map reduce execution plans that are used to compute the specified relationship.
If no script is given:
The logical plan shows a pipeline of operators to be executed to build the relation. Type checking and backend-independent optimizations (such as applying filters early on) also apply.
The physical plan shows how the logical operators are translated to backend-specific physical operators. Some backend optimizations also apply.
The mapreduce plan shows how the physical operators are grouped into map reduce jobs.
If a script without an alias is specified, it will output the entire execution graph (logical, physical, or map reduce).
If a script with a alias is specified, it will output the plan for the given alias.
Example:
Assume we have a file student_data.txt in HDFS with the following content.
And we have read it into a relation student using the LOAD operator as shown below.
Now, explain the relation named student using the explain operator as shown below.
explain command in pigpig illustrate exampleillustrate in pigillustrate operator in pigpig unit testing exampleapache pig unit testingpigunit tutorialhow does a client find the region server hosting a specific row key rangeexplain command in pigpig group by countpig operators with examplespig group allcross join in pigcross piggroup by multiple columns in pigdescribe command in pigpig tutorial apache pig tutorial hadoop pig tutorial pig latin tutorial learn pig pig hadoop pig tutorial point learn pig latin pig big data pig latin hadoop apache pig pig latin pig commands pig hive pig interview questions hadoop pig hive pig script how to learn pig latin pig and hive pig language pig tutorial pdf apache pig tutorial pdf hadoop pig examples pig store pig programming apache pig download pig data pig script example pig group pig storage pig in latin pig order what is apache pig how to read pig latin pig flatten pigstorage flatten in pig pig latin examples pig mapreduce apache pig commands pig commands pdf pig examples pig load pig code guide pig pig jobs store command in pig tutorial peppa pig peppa pig tutorial simple pig how to write in pig latin datapig pig latin program uses of pig