Friday, August 19, 2011

How to debug Pig UDFs in Eclipse?

It is not that hard as you think actually.
  1. Create a maven project using m2eclipse.
  2. Add org.apache.pig:pig as dependency.
  3. Click "Debug configurations ...".
  4. Create a "Java Application".
  5. Main class "org.apache.pig.Main".
  6. In Arguments tab, put "-x local" and other arugments in "Program arguments".
  7. In Environment tab, create a variable "PATH" as "${env_var:path};c:\cygwin\bin" if your OS is Windows.
  8. Debug your script, and Eclipse will stop at the breakpoint you set in UDF.

2 comments:

  1. Hello Ben,

    I created a maven project, and would like to add the dependency (second bullet) but there is no pig dependency available on the catalog. Any suggestion? Thanks,
    Keren

    ReplyDelete
  2. Sorry for late reply. Hope you already resolve the issue.

    I can find the artifact of pig here:
    http://search.maven.org/#search%7Cga%7C1%7Corg.apache.pig

    It is possible that something wrong in your maven settings.
    + Window->Show View->Maven Repository
    + Check if you have "central (http://repo1.maven.org/maven2)" in "Global Repositories"

    ReplyDelete