[ https://issues.apache.org/jira/browse/PIG-3894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13975946#comment-13975946
]
Cheolsoo Park commented on PIG-3894:
------------------------------------
+1. Will commit it shortly.
> 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
> Labels: datetime, easyfix
> Attachments: PIG-3894.patch
>
>
> 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)
|