Return-Path: X-Original-To: apmail-pig-dev-archive@www.apache.org Delivered-To: apmail-pig-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CF4EE11030 for ; Mon, 21 Apr 2014 19:44:17 +0000 (UTC) Received: (qmail 15781 invoked by uid 500); 21 Apr 2014 19:44:16 -0000 Delivered-To: apmail-pig-dev-archive@pig.apache.org Received: (qmail 15705 invoked by uid 500); 21 Apr 2014 19:44:15 -0000 Mailing-List: contact dev-help@pig.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pig.apache.org Delivered-To: mailing list dev@pig.apache.org Received: (qmail 15693 invoked by uid 500); 21 Apr 2014 19:44:15 -0000 Delivered-To: apmail-hadoop-pig-dev@hadoop.apache.org Received: (qmail 15687 invoked by uid 99); 21 Apr 2014 19:44:15 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Apr 2014 19:44:15 +0000 Date: Mon, 21 Apr 2014 19:44:15 +0000 (UTC) From: "Cheolsoo Park (JIRA)" To: pig-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PIG-3894) Datetime function AddDuration, SubtractDuration and all Between functions don't check for null values in the input tuple. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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)