Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8107369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:44:52+00:00 2026-06-06T00:44:52+00:00

When developing Pig scripts that use the STORE command I have to delete the

  • 0

When developing Pig scripts that use the STORE command I have to delete the output directory for every run or the script stops and offers:

2012-06-19 19:22:49,680 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 6000: Output Location Validation Failed for: 'hdfs://[server]/user/[user]/foo/bar More info to follow:
Output directory hdfs://[server]/user/[user]/foo/bar already exists

So I’m searching for an in-Pig solution to automatically remove the directory, also one that doesn’t choke if the directory is non-existent at call time.

In the Pig Latin Reference I found the shell command invoker fs. Unfortunately the Pig script breaks whenever anything produces an error. So I can’t use

fs -rmr foo/bar

(i. e. remove recursively) since it breaks if the directory doesn’t exist. For a moment I thought I may use

fs -test -e foo/bar

which is a test and shouldn’t break or so I thought. However, Pig again interpretes test‘s return code on a non-existing directory as a failure code and breaks.

There is a JIRA ticket for the Pig project addressing my problem and suggesting an optional parameter OVERWRITE or FORCE_WRITE for the STORE command. Anyway, I’m using Pig 0.8.1 out of necessity and there is no such parameter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:44:55+00:00Added an answer on June 6, 2026 at 12:44 am

    At last I found a solution on grokbase. Since finding the solution took too long I will reproduce it here and add to it.

    Suppose you want to store your output using the statement

    STORE Relation INTO 'foo/bar';
    

    Then, in order to delete the directory, you can call at the start of the script

    rmf foo/bar
    

    No “;” or quotations required since it is a shell command.

    I cannot reproduce it now but at some point in time I got an error message (something about missing files) where I can only assume that rmf interfered with map/reduce. So I recommend putting the call before any relation declaration. After SETs, REGISTERs and defaults should be fine.

    Example:

    SET mapred.fairscheduler.pool 'inhouse';
    REGISTER /usr/lib/pig/contrib/piggybank/java/piggybank.jar;
    %default name 'foobar'
    rmf foo/bar
    Rel = LOAD 'something.tsv';
    STORE Rel INTO 'foo/bar';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Developing for iPhone, I have a collection of points that I need to make
Developing with my first Mac and I noticed that my Rspec output isn't colorized
Developing a network application, I have a Connection class that manages sending and receiving
Developing a Sencha Touch MVC app that pulls data from json store (thats set
Developing an app that people pay a monthly subscription to use. They can pay
Iam developing one application.In that i use the google api for getting the location
Iam developing one application.In that i use the google api for getting the location
iam developing one application.In that i use the search bar for search the data.But
Developing Java, you have always learned that its best to create an ArrayList by
Developing for Android 2.3, I have a question regarding layouts. I use a vertival

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.