[ 
https://issues.apache.org/jira/browse/HIVE-6046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13901937#comment-13901937
 ] 

Xuefu Zhang commented on HIVE-6046:
-----------------------------------

[~kostiantyn] Thanks for working on this. The code changes seem fine, but I 
have a couple of high-level questions:

1. The UDF in the patch takes only a date in a string form, which seems too 
restrictive as Hive has a the data type of Date. Hive should be able to output 
the date to any format the user specifies. The udf isn't able to achieve this.

2. The name of the UDF, format_date is questionable, because major DBs provide 
date_format() that does a different thing. This can cause unnecessary confusion.

Thus, to have a bigger usage, I'd suggest the following:
1. provide a UDF, such as to_date(string dateString, String format), that 
converts a given date in the given format to a Date date. to_date is also 
available in Oracle, while mysql has STR_TO_DATE.
2. provide UDF, date_format(Date date, String format) as what Oracle or MySQL 
has.

With these two, you should be able to achieve what you want while retaining 
bigger flexibility and usage.

> add  UDF for converting date time from one presentation to another
> ------------------------------------------------------------------
>
>                 Key: HIVE-6046
>                 URL: https://issues.apache.org/jira/browse/HIVE-6046
>             Project: Hive
>          Issue Type: New Feature
>          Components: UDF
>    Affects Versions: 0.13.0
>            Reporter: Kostiantyn Kudriavtsev
>            Assignee: Kostiantyn Kudriavtsev
>         Attachments: HIVE-6046.patch, Hive-6046.patch
>
>
> it'd be nice to have function for converting datetime to different formats, 
> for example:
> format_date('2013-12-12 00:00:00.0', 'yyyy-MM-dd HH:mm:ss.S', 'yyyy/MM/dd')
> There are two signatures to facilitate further using:
> format_date(datetime, fromFormat, toFormat)
> format_date(timestamp, toFormat)
>  



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to