org.apache.pig.piggybank.evaluation.datetime.convert
Class CustomFormatToISO
java.lang.Object
org.apache.pig.EvalFunc<String>
org.apache.pig.piggybank.evaluation.datetime.convert.CustomFormatToISO
public class CustomFormatToISO
- extends EvalFunc<String>
CustomFormatToISO converts arbitrary date formats to ISO format.
Jodatime: http://joda-time.sourceforge.net/
ISO8601 Date Format: http://en.wikipedia.org/wiki/ISO_8601
Jodatime custom date formats: http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html
Example usage:
REGISTER /Users/me/commiter/piggybank/java/piggybank.jar ;
REGISTER /Users/me/commiter/piggybank/java/lib/joda-time-1.6.jar ;
DEFINE CustomFormatToISO org.apache.pig.piggybank.evaluation.datetime.convert.CustomFormatToISO();
CustomIn = LOAD 'test3.tsv' USING PigStorage('\t') AS (dt:chararray);
DESCRIBE CustomIn;
CustomIn: {dt: chararray}
DUMP CustomIn;
(10-1-2010)
toISO = FOREACH CustomIn GENERATE CustomFormatToISO(dt, "MM-dd-YYYY") AS ISOTime:chararray;
DESCRIBE toISO;
toISO: {ISOTime: chararray}
DUMP toISO;
(2010-10-01T00:00:00.000Z)
...
Methods inherited from class org.apache.pig.EvalFunc |
finish, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, isAsynchronous, progress, setPigLogger, setReporter, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CustomFormatToISO
public CustomFormatToISO()
exec
public String exec(Tuple input)
throws IOException
- Description copied from class:
EvalFunc
- This callback method must be implemented by all subclasses. This
is the method that will be invoked on every Tuple of a given dataset.
Since the dataset may be divided up in a variety of ways the programmer
should not make assumptions about state that is maintained between
invocations of this method.
- Specified by:
exec
in class EvalFunc<String>
- Parameters:
input
- the Tuple to be processed.
- Returns:
- result, of type T.
- Throws:
IOException
outputSchema
public Schema outputSchema(Schema input)
- Overrides:
outputSchema
in class EvalFunc<String>
- Parameters:
input
- Schema of the input
- Returns:
- Schema of the output
getArgToFuncMapping
public List<FuncSpec> getArgToFuncMapping()
throws FrontendException
- Overrides:
getArgToFuncMapping
in class EvalFunc<String>
- Returns:
- A List containing FuncSpec objects representing the Function class
which can handle the inputs corresponding to the schema in the objects
- Throws:
FrontendException
Copyright © ${year} The Apache Software Foundation