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

Oliver Lee commented on CALCITE-5533:
-------------------------------------

cc [~julianhyde]

> Unclear type name in FamilyOperandTypeChecker getAllowedSignature()
> -------------------------------------------------------------------
>
>                 Key: CALCITE-5533
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5533
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Oliver Lee
>            Priority: Minor
>
> The error message from {{getAllowedSignature()}} for 
> {{FamilyOperandTypeChecker}} [uses the SqlTypeFamily 
> |https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java#L190]instead
>  of the actual type that is used in the function call.
>  
> For example this query using the Big Query dialect (context: BQ {{TIMESTAMP}} 
> is Calcite's {{TIMESTAMP_WITH_LOCAL_TIME_ZONE}})
> {quote}SELECT TIMESTAMP_DIFF(1, TIMESTAMP "2008-12-25 15:30:00", HOUR)
> {quote}
> You would expect the error message in the current state to be produced using 
> Calcite types:
> {quote}Cannot apply 'TIMESTAMP_DIFF' to arguments of type 
> 'TIMESTAMP_DIFF(<INTEGER>, <TIMESTAMP_WITH_LOCAL_TIME_ZONE(0)>, <INTERVAL 
> HOUR>)'. Supported form(s): 
> 'TIMESTAMP_DIFF(<+TIMESTAMP_WITH_LOCAL_TIME_ZONE+>, 
> <+TIMESTAMP_WITH_LOCAL_TIME_ZONE+>, <ANY>)'
> {quote}
> However the error message is actually:
>  
> {quote}Cannot apply 'TIMESTAMP_DIFF' to arguments of type 
> 'TIMESTAMP_DIFF(<INTEGER>, <TIMESTAMP_WITH_LOCAL_TIME_ZONE(0)>, <INTERVAL 
> HOUR>)'. Supported form(s): 'TIMESTAMP_DIFF(<+TIMESTAMP+>, <+TIMESTAMP+>, 
> <ANY>)'
> {quote}
>  
> The 
> [TIMESTAMP_DIFF|https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java#L811]
>  function checks that the operands are from the 
> [SqlTypeFamily.TIMESTAMP|https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFamily.java#L182]
>  type family and the error message [uses the family 
> name|https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java#L190]
>  SqlTypeFamily.TIMESTAMP,  not the SqlTypeName  
> [SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE|https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFamily.java#L183].
>  
>  



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

Reply via email to