Type: New Feature
Affects Version/s: None
Fix Version/s: 0.9.0
As production Pig scripts grow longer and longer, Pig Latin has a need to integrate standard programming techniques of separation and code sharing offered by functions and modules. A proposal of adding macro expansion to Pig Latin is posted here: http://wiki.apache.org/pig/TuringCompletePig
Below is a brief summary of the proposed syntax (and examples):
- Macro Definition
The existing DEFINE keyword will be expanded to allow definitions of Pig macros.
- Macro Expansion
Example: Use above macro in a Pig script:
This script is expanded into the following Pig Latin statements:
1. Any alias in the macro which isn't visible from outside will be prefixed with macro name and suffixed with instance id to avoid namespace collision.
2. Macro expansion is not a complete replacement for function calls. Recursive expansions are not supported.
- Macro Import
The new IMPORT keyword can be used to add macros defined in another Pig Latin file.
Note: All macro names are in the global namespace.