Jenny Thompson created PIG-3894:
-----------------------------------

             Summary: Datetime function AddDuration, SubtractDuration and all 
Between functions don't check for null values in the input tuple.
                 Key: PIG-3894
                 URL: https://issues.apache.org/jira/browse/PIG-3894
             Project: Pig
          Issue Type: Bug
            Reporter: Jenny Thompson


The simple datetime functions: GetMonth, GetHour, ToDate, GetYear etc all have 
safe treatment of null values in the input tuple.

e.g.
{code:title=GetMonth.java|borderStyle=solid}
@Override
public Integer exec(Tuple input) throws IOException {
    if (input == null || input.size() < 1 || input.get(0) == null) {
        return null;
    }
    return ((DateTime) input.get(0)).getMonthOfYear();
}
{code}

However, all of the "Duration" or "Between" functions are missing this 
null-checking, and so fail completely when the are passed tuples with null 
values.

e.g.
{code:title=AddDuration.java|borderStyle=solid}
@Override
public DateTime exec(Tuple input) throws IOException {
    if (input == null || input.size() < 2) {
        return null;
    }
    return ((DateTime) input.get(0)).plus(new Period((String) input.get(1)));
}
{code}

This is inconsistent, problematic and easy to fix.




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to