You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Binitha R B (JIRA)" <ji...@apache.org> on 2013/02/05 11:20:13 UTC

[jira] [Updated] (PIG-1151) Date Conversion + Arithmetic UDFs

     [ https://issues.apache.org/jira/browse/PIG-1151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Binitha R B updated PIG-1151:
-----------------------------

                 Tags: pig,date,udf
               Labels: patch  (was: )
    Affects Version/s:     (was: 0.5.0)
                       0.10.0
         Hadoop Flags: Incompatible change
               Status: Patch Available  (was: Open)

Submitting the patch for arithmetic operations on date and date comparison
                
> Date Conversion + Arithmetic UDFs
> ---------------------------------
>
>                 Key: PIG-1151
>                 URL: https://issues.apache.org/jira/browse/PIG-1151
>             Project: Pig
>          Issue Type: New Feature
>    Affects Versions: 0.10.0
>            Reporter: sam rash
>            Priority: Minor
>              Labels: patch
>
> I would like to offer up some very simple data UDFs I have that wrap JodaTime (apache 2.0 license, http://joda-time.sourceforge.net/license.html) and operate on ISO8601 date strings.
> (for piggybank).  Please advise if these are appropriate.
> 1. Date Arithmetic
> takes an input string: 
> 2009-01-01T13:43:33.000Z
> (and partial ones such as 2009-01-02)
> and a timespan (as millis or as string shorthand)
> returns an ISO8601 string that adjusts the input date by the specified timespan
> DatePlus(long timeMs); // + or - number works, is the # of millis
> DatePlus(String timespan); //10m = 10 minutes, 1h = 1 hour, 1172 ms, etc
> DateMinus(String timespan); //propose explicit minus when using string shorthand for time periods
> 2. Date Comparison (when you don't have full strings that you can use string compare with):
> DateIsBefore(String dateString); //true if lhs is before rhs
> DateIsAfter(String dateString); //true if lsh is after rhs
> 3. date trunc functions:
> takes partial ISO8601 strings and truncates to:
> toMinute(String dateString);
> toHour(String dateString);
> toDay(String dateString);
> toWeek(String dateString);
> toMonth(String dateString);
> toYear(String dateString);
> if any/all are helpful, I'm happy to contribute to pig

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira