It is a bit late for this answer, but I recently worked on this requirement and did not find anything useful until I found it, hope this helps someone to need it:
** This excerpt is from the Pig programming book.
Over time, in Pig Latin, the entire script should be in one file. This led to some rather unpleasant diverse Pig Latin scripts. Starting at 0.9, a preprocessor can be used to turn one swallow script into another. Taken together with macros, you can now write a modular Pig Latin, which is easier to debug and reuse: import is used to include one Pig Latin script in another:
- main.pig
import '../examples/ch6/dividend_analysis.pig'; daily = load 'NYSE_daily' as (exchange:chararray, symbol:chararray, date:chararray, open:float, high:float, low:float, close:float, volume:int, adj_close:float); results = dividend_analysis(daily, '2009', 'symbol', 'open', 'close');
import writes the imported file directly to your Pig Latin script instead of importing. In the previous example, the contents of divend_analysis.pig will be placed immediately before the load instruction. Please note that the file cannot be imported twice. If you want to use the same function several times, you must write it as a macro and import a file with this macro.
source share