Description
Today, if you want to parse a date or timestamp, you have to use the unix time function and then cast to a timestamp. Its a little odd there isn't a single function that does both. I propose we add
to_date(<input>, <pattern>)/to_timestamp(<input>, <pattern>).
For reference, in other systems there are:
MS SQL: convert(<input>, <pattern id>). See: https://technet.microsoft.com/en-us/library/ms174450(v=sql.110).aspx
Netezza: to_timestamp(<input>, <pattern>). See: https://www.ibm.com/support/knowledgecenter/SSULQD_7.0.3/com.ibm.nz.dbu.doc/r_dbuser_ntz_sql_extns_conversion_funcs.html
Teradata has special casting functionality: cast(<input> as timestamp format '<pattern>')
MySql: STR_TO_DATE(<input>, <pattern>). This returns a datetime when you define both date and time parts. See: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
Attachments
Issue Links
- is duplicated by
-
SPARK-18424 Single Function for Parsing Dates and Times with Formats
- Resolved
- is related to
-
SPARK-18214 Simplify RuntimeReplaceable type coercion
- Resolved
- links to