OSDir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Review Request 67073: HIVE-19370 : Retain time part in add_months function on timestamp datatype fields in hive



> On May 11, 2018, 8:51 p.m., Bharathkrishna Guruvayoor Murali wrote:
> > Should I handle String inputs like 2018-05-10 12:20:10 to retain the time part.
> > I did not do this because the inputs can have several formats if it is String (whereas timestamp is only in one format and it was easier to handle).
> > 
> > Should I add an extra parameter in the UDF that accepts an optional DateFormat string, where user can pass the format they want the output to be in. If the parser fails, I can fallback to the default format.
> > What are your thoughts on this.
> 
> Peter Vary wrote:
>     I think using the approach we see in GenericUDFDateFormat we will have consistent behaviour across different UDF-s.
>     What do you think?

So the problem that I see is that, String format can have different types of strings, like yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss.fff, so it is difficult to provide the output in the same format as input.
Also, String format can have just YYYY-MM-dd (without time), in this case, we should be having logic to not have time in output, otherwise it will be of form YYYY-MM-dd 00:00:00

The GenericUDFDateFormat uses a dateformat value, which helps convert the String to given format, so there are no ambiguities about output format.
That is why I wanted to add extra parameter in the UDF for output DateFormat.


- Bharathkrishna


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/67073/#review202965
-----------------------------------------------------------


On May 10, 2018, 9:55 p.m., Bharathkrishna Guruvayoor Murali wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/67073/
> -----------------------------------------------------------
> 
> (Updated May 10, 2018, 9:55 p.m.)
> 
> 
> Review request for hive, Peter Vary, Sahil Takiar, and Vihang Karajgaonkar.
> 
> 
> Repository: hive-git
> 
> 
> Description
> -------
> 
> Adding support to retain the time part (HH:mm:ss) for add_months UDF when the input is given as timestamp format.
> 
> 
> Diffs
> -----
> 
>   common/src/java/org/apache/hive/common/util/DateUtils.java 65f3b9401916abdfa52fbf75d115ba6b61758fb0 
>   ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFAddMonths.java dae4b97b4a17e98122431e5fda655fd9f873fdb5 
>   ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFAddMonths.java af9b6c43c7dafc69c4944eab02894786af306f35 
> 
> 
> Diff: https://reviews.apache.org/r/67073/diff/1/
> 
> 
> Testing
> -------
> 
> Added unit tests.
> 
> 
> Thanks,
> 
> Bharathkrishna Guruvayoor Murali
> 
>