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