Database Reference
In-Depth Information
filefrom
www.wiley.com/go/microsoftbigdatasolutions
,
whichisreferenced
by the
piggybank.jar
file.
Place the jar files in a directory accessible to the Pig command-line console;
for example, you can place it in the same directory as the
pig.jar
file. Now
you can register and alias the PiggyBank functions in your Pig Latin scripts.
The first function you use here is the
CustomFormatToISO
. This function
converts the date/time strings in the file to a standard ISO format:
REGISTER
'C:\hdp\hadoop\pig-0.11.0.1.3.0.0-0380\piggybank.jar';
REGISTER
'C:\hdp\hadoop\pig-0.11.0.1.3.0.0-0380\joda-time-2.2.jar';
DEFINE Convert
org.apache.pig.piggybank.evaluation.datetime.convert.CustomFormatToISO;
Use the following code to load and convert the date/time values:
SpeedData = LOAD '/user/test/traffic.txt' using
PigStorage()
AS (dtstamp:chararray, sensorid:int, speed:double);
SpeedDataFormat = FOREACH SpeedData Generate dtstamp,
Convert(dtstamp,'MM/dd/YYYY hh:mm:ss a') as dtISO;
Dump SpeedDataFormat;
After the job completes, you should see data similar to the data shown in