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

James Mcguire commented on FLINK-31320:
---------------------------------------

Looks like we have a PR for this one: https://github.com/apache/flink/pull/22353

> Modify DATE_FORMAT system (built-in) function to accepts DATEs
> --------------------------------------------------------------
>
>                 Key: FLINK-31320
>                 URL: https://issues.apache.org/jira/browse/FLINK-31320
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API
>            Reporter: James Mcguire
>            Priority: Minor
>              Labels: pull-request-available
>
> The current {{DATE_FORMAT}} function only supports {{{}TIMESTAMP{}}}s. 
> (See 
> https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/functions/systemfunctions/#temporal-functions)
>  
> Ideally, it should be able to format {{{}DATE{}}}'s as well as {{TIMESTAMPs}}
>  
> Example usage:
> {noformat}
> Flink SQL> CREATE TABLE test_table (
> >   some_date DATE,
> >   object AS JSON_OBJECT(
> >     KEY 'some_date' VALUE DATE_FORMAT(some_date, 'YYYY-MM-dd')
> >   )
> > )
> > COMMENT ''
> > WITH (
> >   'connector'='datagen'
> > )
> > ;
> > 
> [ERROR] Could not execute SQL statement. Reason:
> org.apache.calcite.sql.validate.SqlValidatorException: Cannot apply 
> 'DATE_FORMAT' to arguments of type 'DATE_FORMAT(<DATE>, <CHAR(10)>)'. 
> Supported form(s): 'DATE_FORMAT(<TIMESTAMP>, <STRING>)'
> 'DATE_FORMAT(<STRING>, <STRING>)'{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to