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

juntaozhang edited comment on CALCITE-7021 at 5/20/25 3:23 PM:
---------------------------------------------------------------

Hi team, I volunteer to solve this task.

I search {_}ISO/IEC 9075-2:2023{_}, find this is not SQL standard, so I will 
add a flag named `includeIntervalWithoutQualifier` to ctrl the logic of `<cast 
specification>`:
{code:java}
if includeIntervalWithoutQualifier=true:
    will tranform CAST(VALUE as INTERVAL) ==> CAST(VALUE as INTERVAL SECOND)
else 
   will throw ParseException.
{code}
 

config.fmpp in babel of Postgres will set includeIntervalWithoutQualifier=true

 

FYI in {_}ISO/IEC 9075-2:2023{_}:
{code:java}
<cast specification> ::= CAST <left paren> <cast operand> AS<cast target> [ 
FORMAT <cast template> ] <right paren>
<cast target> ::= <domain name> | <data type>
<data type> ::= ... | <interval type> |...
<interval type> ::= INTERVAL <interval qualifier>
{code}


was (Author: juntaozhang):
Hi team, I volunteer to solve this task.


I search {_}ISO/IEC 9075-2:2023{_}, find this is not SQL standard, so I will 
add a flag named `includeIntervalWithoutQualifier` to ctrl the logic of `<cast 
specification>`:
{code:java}
if includeIntervalWithoutQualifier=true:
    will tranform CAST(VALUE as INTERVAL) ==> CAST(VALUE as INTERVAL SECOND)
else 
   will throw ParseException.
{code}
 

FYI in {_}ISO/IEC 9075-2:2023{_}:
{code:java}
<cast specification> ::= CAST <left paren> <cast operand> AS<cast target> [ 
FORMAT <cast template> ] <right paren>
<cast target> ::= <domain name> | <data type>
<data type> ::= ... | <interval type> |...
<interval type> ::= INTERVAL <interval qualifier>
{code}

> Support parse 'CAST('1' AS INTERVAL)' 
> --------------------------------------
>
>                 Key: CALCITE-7021
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7021
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: xiong duan
>            Priority: Major
>
> Now we have supported :
> {code:java}
> CAST(VALUE as INTERVAL YEAR)、CAST(VALUE as INTERVAL MONTH)、CAST(VALUE as 
> INTERVAL DAY)、
> CAST(VALUE as INTERVAL HOUR)、CAST(VALUE as INTERVAL MINUTES)、CAST(VALUE as 
> INTERVAL SECOND)
> {code}
> In postgreSQL:
> {code:java}
> CAST(VALUE as INTERVAL) ==> CAST(VALUE as INTERVAL SECOND)
> select cast('1' as  interval);
> select cast('1' as  interval second);
> ==>00:00:01
> {code}



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

Reply via email to