Jacob Tolar created PIG-5425: -------------------------------- Summary: Pig 0.15 and later don't set context signature correctly Key: PIG-5425 URL: https://issues.apache.org/jira/browse/PIG-5425 Project: Pig Issue Type: Improvement Reporter: Jacob Tolar
As an author of Pig UDFs, my expectation in EvalFunc ( [https://github.com/apache/pig/blob/release-0.17.0/src/org/apache/pig/EvalFunc.java] ) is that {{setUDFContextSignature}} would be called before {{setInputSchema}}. This was previously the case up through Pig 0.14 In Pig 0.15 and later (according to the git tags, at least; I've only checked 0.17), this is not true. This commit introduces the problem behavior: [https://github.com/apache/pig/commit/8af34f1971628d1eeb0cd1f07fe03397ca887b81] The issue is in src/org/apache/pig/newplan/logical/expression/ExpToPhyTranslationVisitor.java line 513 ([git blame link|https://github.com/apache/pig/blame/release-0.17.0/src/org/apache/pig/newplan/logical/expression/ExpToPhyTranslationVisitor.java#L513]) introduced in that commit. There, {{f.setInputSchema()}} is called without previously calling {{f.setUDFContextSignature(signature)}}. Note that on line 509, {{((POUserFunc)p).setSignature(op.getSignature());}} is called, but POUserFunc [re-instantiates the EvalFunc and does not actually use the func argument passed in its constructor|https://github.com/apache/pig/blame/release-0.17.0/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java#L119-L128] (quite confusing, but probably attributable to changes over time). {{f}} is discarded, so it should be safe to simply call {{f.setUdfContextSignature(signature)}} as a simple fix. The code here is arguably unnecessarily complex and could probably be cleaned up further, but I propose the simple fix above without a larger refactoring. -- This message was sent by Atlassian Jira (v8.20.10#820010)