You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Aurora Skarra-Gallagher <au...@yahoo-inc.com> on 2011/03/12 01:45:16 UTC
Re: In UDAF, possible for terminatePartial to be called without
init?
Anyone know the answer to this?
Thanks,
Aurora
On Feb 15, 2011, at 8:53 AM, Aurora Skarra-Gallagher wrote:
> Hi,
>
> I wrote a simple UDAF for Hive 0.6 and I had to include null checks in terminatePartial even though the object should never be null if init is always called before terminatePartial.
>
> For instance, my init function:
> public void init() {
> result = new StringBuffer();
> }
>
> My terminatePartial function:
> public String terminatePartial() {
> if (result == null) {
> return new String();
> }
>
> // Remove trailing comma, if string isn't blank
> if (result.length() > 0 && result.charAt(result.length() - 1) == ',') {
> result.deleteCharAt(result.length() - 1);
> }
>
> return result.toString();
> }
>
> If I don't have that initial null check, when the results are empty that I'm applying my UDAF to, I get a NullPointerException. It makes me think that terminatePartial can be called with no init call. Is that possible?
>
> Thanks,
> Aurora