@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Integer numMonthV; if (isNumMonthsConst) { numMonthV = numMonthsConst; } else { numMonthV = getIntValue(arguments, 1, converters); } if (numMonthV == null) { return null; } int numMonthInt = numMonthV.intValue(); Date date = getDateValue(arguments, 0, inputTypes, converters); if (date == null) { return null; } addMonth(date, numMonthInt); Date newDate = calendar.getTime(); output.set(DateUtils.getDateFormat().format(newDate)); return output; }
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Integer numMonthV; if (isNumMonthsConst) { numMonthV = numMonthsConst; } else { numMonthV = getIntValue(arguments, 1, tsConverters); } if (numMonthV == null) { return null; } int numMonthInt = numMonthV.intValue(); // the function should support both short date and full timestamp format // time part of the timestamp should not be skipped Timestamp ts = getTimestampValue(arguments, 0, tsConverters); if (ts != null) { addMonth(ts, numMonthInt); } else { Date date = getDateValue(arguments, 0, dtInputTypes, dtConverters); if (date != null) { addMonth(date, numMonthInt); } else { return null; } } String res = formatter.format(calendar.getTime()); output.set(res); return output; }
@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { Integer numMonthV; if (isNumMonthsConst) { numMonthV = numMonthsConst; } else { numMonthV = getIntValue(arguments, 1, converters); } if (numMonthV == null) { return null; } int numMonthInt = numMonthV.intValue(); Date date = getDateValue(arguments, 0, inputTypes, converters); if (date == null) { return null; } addMonth(date, numMonthInt); Date newDate = calendar.getTime(); output.set(DateUtils.getDateFormat().format(newDate)); return output; }