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

Jerin John edited comment on CALCITE-6092 at 11/7/23 1:04 AM:
--------------------------------------------------------------

It is a duplicate report from CALCITE-5957 but I suppose the fix is not 
available yet, I believe {{cast('1241241' as TIME)}} should also be included 
under this [BUG 
condition|https://github.com/apache/calcite/commit/f996bc9993546019d0fd475b2daa99ac8b1b9259#diff-fdd0c725fc7c6fd56965f59b1d51e4c7a9b5b5be27da2e54b8b8273dc980cd64R1257-R1258]
 just as {{cast to TIMESTAMP}} cases are handled as an exception, until the new 
Avatica version fixes the time string validation.


was (Author: JIRAUSER301314):
It is a duplicate report but I suppose the fix is not available yet, I believe 
{{cast('1241241' as TIME)}} should also be included under this [BUG 
condition|https://github.com/apache/calcite/commit/f996bc9993546019d0fd475b2daa99ac8b1b9259#diff-fdd0c725fc7c6fd56965f59b1d51e4c7a9b5b5be27da2e54b8b8273dc980cd64R1257-R1258]
 just as {{cast to TIMESTAMP}} cases are handled as an exception, until the new 
Avatica version fixes the time string validation.

> Invalid test cases in CAST String to Time
> -----------------------------------------
>
>                 Key: CALCITE-6092
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6092
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jerin John
>            Priority: Major
>
> Encountered some 
> [tests|https://github.com/apache/calcite/blob/590ec85f0fcff7173c288c350c3f60e640976a34/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java#L1237-L1238]
>  within SqlOperatorTest file for the CAST operator on String to Datetime 
> conversions, which are found to be invalid time strings on some tested 
> instances of DBs like BQ, MySql, Postgres.
> It seems these tests were originally ignored as `BAD_DATETIME_MESSAGE` but 
> then updated to verify conversion performed by the CAST operator (refer to 
> JIRA ticket: CALCITE-5554 and 
> [commit|https://github.com/apache/calcite/commit/625a2e03c4c5583279350bf04e3db2a31b1ec411#diff-fdd0c725fc7c6fd56965f59b1d51e4c7a9b5b5be27da2e54b8b8273dc980cd64R1118-R1119])
> Example test case (L1223):
> {{cast('1241241' as TIME)}} | expected: "72:40:12" | actual: "16:40:12"
> The string '1241241' is being parsed as number of hours, and internal 
> conversion into milliseconds is done as {{{}1241241 * (int) MILLIS_PER_HOUR 
> }} which results in na INT overflow.
> The resultant overflowed value is 1701612160 milliseconds = 472.670044444 
> hours, and 472 % 24 is 16 (and .67 is roughly 2/3 so 40ish minutes seems 
> legit) 
> Considering that multiple dialects catch these cases as invalid time strings 
> for conversion, code should be updated to handle them as exceptions and the 
> tests to be corrected to reflect this behavior.



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

Reply via email to