- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
PIG UDFs Python - Gurantee that String have the format 'yyyy-MM-dd hh:ss:mm'
- Labels:
-
Apache Pig
Created on ‎08-02-2016 09:21 AM - edited ‎09-16-2022 03:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi experts,
I've the following part of script in Apache Pig:
....
A = foreach Source_Data generate (int) ID,
ToString( ToDate((long) Time), 'yyyy-MM-dd hh:ss:mm') as date,
(int) Code;
Store A into '.../newfile'; ...
Now I want to create a new Script using Python UDF to guarantee that in my newfile on column Date (#1) I only have String in the format 'yyyy-MM-dd hh:ss:mm'.
Is possible to do that?
Many thanks!
Created ‎08-03-2016 06:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you can write a new script using regex to test this column and throw away bad fields or do it all in one step where you pass the date field to UDF and check for formatting
Created ‎08-03-2016 06:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you can write a new script using regex to test this column and throw away bad fields or do it all in one step where you pass the date field to UDF and check for formatting
