[
https://issues.apache.org/jira/browse/PIG-969?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12994532#comment-12994532
]
Thejas M Nair commented on PIG-969:
-----------------------------------
I can't think of why I originally suggested that it is better to disable the
constructor argument feature earlier! Both option 1 and 3 seems reasonable to
me.
But i tried a quick test with 0.8 and it seems to be trying to instantiate the
constructor of class returned by argsToFuncMapping() with the constructor
arguments in define. ie, it is using option 1. But I am not sure if this is the
same behavior in earlier versions of pig. If not, going with option 1 might not
be backward compatible.
I think it is a matter of deciding between these two options, adding some unit
tests and documenting it.
I will not be able to work on this in next few days. So if anybody would like
to drive this, please feel free to reassign the jira.
> Default constructor of UDF gets called for UDF with parameterised constructor
> , if the udf has a getArgToFuncMapping function defined
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: PIG-969
> URL: https://issues.apache.org/jira/browse/PIG-969
> Project: Pig
> Issue Type: Bug
> Components: impl
> Reporter: Thejas M Nair
> Assignee: Thejas M Nair
> Fix For: 0.9.0
>
>
> This issue is discussed in
> http://www.mail-archive.com/[email protected]/msg00524.html . I am
> able to reproduce the issue. While it is easy to fix the udf, it can take a
> lot of time to figure out the problem (until they find this email
> conversation!).
> The root cause is that when getArgToFuncMapping is defined in the udf , the
> FuncSpec returned by the method replaces one set by define statement . The
> constructor arguments get lost. We can handle this in following ways -
> 1. Preserve the constructor arguments, and use it with the class name of the
> matching FuncSpec from getArgToFuncMapping .
> 2. Give an error if constructor paramerters are given for a udf which has
> FuncSpecs returned from getArgToFuncMapping .
> The problem with approach 1 is that we are letting the user define the
> FuncSpec , so user could have defined a FuncSpec with constructor (though
> they don't have a valid reason to do so.). It is also possible the the
> constructor of the different class that matched might not support same
> constructor parameters. The use of this function outside builtin udfs are
> also probably not common.
> With option 2, we are telling the user that this is not a supported use case,
> and user can easily change the udf to fix the issue, or use the udf which
> would have matched given parameters (which unlikely to have the
> getArgToFuncMapping method defined).
> I am proposing that we go with option 2 .
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira