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

Fernando Díaz edited comment on FLINK-6895 at 3/15/18 12:27 PM:
----------------------------------------------------------------

Taking a look at this [MySQL 
STR_TO_DATE|https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date]
 it seems that the correct approach would be:
* Return a DATETIME ({{java.sql.Timestamp}}) value if the format string 
contains both date and time parts.
* Return a DATE ({{java.sql.Date}}) if the string contains date only.
* Return a TIME ({{java.sql.Time}}) if the string contains time only.

{{java.util.Date}} it's a superclass of these three classes (see [Class 
Date|https://docs.oracle.com/javase/7/docs/api/java/util/Date.html]). What do 
you think? Maybe it's a good idea to use this as the return type.


was (Author: fdiazgon):
Taking a look at this [MySQL 
STR_TO_DATE]https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date]
 it seems that the correct approach would be:
* Return a DATETIME ({{java.sql.Timestamp}}) value if the format string 
contains both date and time parts.
* Return a DATE ({{java.sql.Date}}) if the string contains date only.
* Return a TIME ({{java.sql.Time}}) if the string contains time only.

{{java.util.Date}} it's a superclass of these three classes (see [Class 
Date|https://docs.oracle.com/javase/7/docs/api/java/util/Date.html]). What do 
you think? Maybe it's a good idea to use this as the return type.

> Add STR_TO_DATE supported in SQL
> --------------------------------
>
>                 Key: FLINK-6895
>                 URL: https://issues.apache.org/jira/browse/FLINK-6895
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>    Affects Versions: 1.4.0
>            Reporter: sunjincheng
>            Assignee: Aegeaner
>            Priority: Major
>
> STR_TO_DATE(str,format) This is the inverse of the DATE_FORMAT() function. It 
> takes a string str and a format string format. STR_TO_DATE() returns a 
> DATETIME value if the format string contains both date and time parts, or a 
> DATE or TIME value if the string contains only date or time parts. If the 
> date, time, or datetime value extracted from str is illegal, STR_TO_DATE() 
> returns NULL and produces a warning.
> * Syntax:
> STR_TO_DATE(str,format) 
> * Arguments
> **str: -
> **format: -
> * Return Types
>   DATAETIME/DATE/TIME
> * Example:
>   STR_TO_DATE('01,5,2013','%d,%m,%Y') -> '2013-05-01'
>   SELECT STR_TO_DATE('a09:30:17','a%h:%i:%s') -> '09:30:17'
> * See more:
> ** [MySQL| 
> https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_str-to-date]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to