[Solved-1 Solution] How to debug a pig script ?



What is Pig Script ?

  • Pig is a high level scripting language that is used with Apache Hadoop. Pig enables data workers to write complex data transformations without knowing Java. Pig’s simple SQL-like scripting language is called Pig Latin, and appeals to developers already familiar with scripting languages and SQL.

What is Debug ?

  • debugging involves locating and correcting code errors in a computer program.

Problem:

How to debug a Pig Script ?

Solution 1:

  • There are several method to debug a pig script. Simple method is step by step execution of a relation and then verify the result.

These commands are useful to debug a pig script.

Dump

  • Use the DUMP operator to run (execute) Pig Latin statements and display the results to your screen.

Illustrate

  • Use the ILLUSTRATE operator to review how data is transformed through a sequence of Pig Latin statements. ILLUSTRATE allows you to test your programs on small datasets and get faster turnaround times.

Explain

  • Use the EXPLAIN operator to review the logical, physical, and map reduce execution plans that are used to compute the specified relationship.

Describe

  • Use the DESCRIBE operator to view the schema of a relation. You can view outer relations as well as relations defined in a nested FOREACH statement.

If you want to debug whole script during execution then you need to write below code at top of your script

-- set the debug mode on 
SET debug 'on'
-- set a job name of your job.
SET job.name 'my job'

This will allow to run your script into debug mode.


Related Searches to How to debug a pig script ?