You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Mike Peterson (JIRA)" <ji...@apache.org> on 2013/11/14 21:07:21 UTC
[jira] [Updated] (PIG-3574) ToDate() can't handle some custom time
formats
[ https://issues.apache.org/jira/browse/PIG-3574?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mike Peterson updated PIG-3574:
-------------------------------
Description:
When trying to parse a string with a format as follows *Fri Nov 01 12:30:19 EDT 2013* there is no way to properly escape the EDT timezone. Both SimpleDate and Joda time provide the single quote character ' to escape custom text (see the examples [here|http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html#timezone] and documentation [here|http://www.joda.org/joda-time/key_format.html], respectively). However, using this violates Pigs grammar and results in an error.
This can be successfully escaped by using something like *ToDate(date,'EEE MMM dd HH:mm:ss \'EDT\' yyyy', 'EST')* and a date time will be returned. This introduces new problems, when you try something like a filter, the next line will throw an error (usually mismatched input '(' expecting SEMI_COLON). I believe this is a result of violating Pigs grammar once again.
The problem here is that any datetime string that has a custom format can't be parsed (such as *Nov 11th at 12:05*, both due to the *th* and the *at*).
was:
When trying to parse a string with a format as follows *Fri Nov 01 12:30:19 EDT 2013* there is no way to properly escape the EDT timezone. Both SimpleDate and Joda time provide the single quote character ' to escape custom text (see the examples [here|http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html#timezone] and documentation [here|http://www.joda.org/joda-time/key_format.html], respectively). However, using this violates Pigs grammar and results in an error.
This can be successfully escaped by using something like \'EDT\' and a date time will be returned. This introduces new problems, when you try something like a filter, the next line will throw an error (usually mismatched input '(' expecting SEMI_COLON). I believe this is a result of violating Pigs grammar once again.
> ToDate() can't handle some custom time formats
> ----------------------------------------------
>
> Key: PIG-3574
> URL: https://issues.apache.org/jira/browse/PIG-3574
> Project: Pig
> Issue Type: Bug
> Affects Versions: 0.11, 0.12.0, 0.11.1
> Reporter: Mike Peterson
>
> When trying to parse a string with a format as follows *Fri Nov 01 12:30:19 EDT 2013* there is no way to properly escape the EDT timezone. Both SimpleDate and Joda time provide the single quote character ' to escape custom text (see the examples [here|http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html#timezone] and documentation [here|http://www.joda.org/joda-time/key_format.html], respectively). However, using this violates Pigs grammar and results in an error.
> This can be successfully escaped by using something like *ToDate(date,'EEE MMM dd HH:mm:ss \'EDT\' yyyy', 'EST')* and a date time will be returned. This introduces new problems, when you try something like a filter, the next line will throw an error (usually mismatched input '(' expecting SEMI_COLON). I believe this is a result of violating Pigs grammar once again.
> The problem here is that any datetime string that has a custom format can't be parsed (such as *Nov 11th at 12:05*, both due to the *th* and the *at*).
--
This message was sent by Atlassian JIRA
(v6.1#6144)