[
https://issues.apache.org/jira/browse/PIG-2850?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13440824#comment-13440824
]
Matthew Hayes commented on PIG-2850:
------------------------------------
The function could legitimately return null if the macro file is not found as a
file or a resource. I thought an error about a resource not being found could
be cryptic if the user isn't expecting this behavior when importing the macro
file. So I checked for null in getMacroFile after attempting to fetch as a
resource and then threw and exception about the file not being found.
Alternatively I could throw a ResourceNotFoundException in fetchResource and
catch this in getMacroFile. See diff #3 where I am doing this instead.
Thanks!
> Pig should support loading macro files as resources stored in JAR files
> -----------------------------------------------------------------------
>
> Key: PIG-2850
> URL: https://issues.apache.org/jira/browse/PIG-2850
> Project: Pig
> Issue Type: Improvement
> Reporter: Matthew Hayes
> Priority: Minor
> Attachments: import_macros_from_jar_2.diff,
> import_macros_from_jar_3.diff, import_macros_from_jar.diff
>
>
> A file containing macros can be imported in pig like so:
> {code}
> IMPORT 'some_path/my_macros.pig';
> {code}
> It would be convenient if a macro file could be imported from a registered
> JAR as well. This would make it easier to distribute them. One could
> package a set of UDFs and macros in a single JAR. Once the JAR is registered
> any of the UDFs or macros can be used once.
> For example, support that {{some_path/my_macros.pig}} has been packaged in a
> JAR named {{my_macros.jar}}. The above code then becomes
> {code}
> REGISTER my_macros.jar;
> IMPORT 'some_path/my_macros.pig';
> {code}
> Pig would first check if the file is found at the path
> {{some_path/my_macros.pig}}, and failing that it would attempt to load a
> resource by that name. Since the JAR is registered it will find it.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira