Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Reviewed
Description
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) 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 (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.