You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Iurii Gerzhedovich (Jira)" <ji...@apache.org> on 2024/06/27 05:50:00 UTC

[jira] [Comment Edited] (CALCITE-6433) SUBSTRING can return incorrect empty result for some parameters

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

Iurii Gerzhedovich edited comment on CALCITE-6433 at 6/27/24 5:49 AM:
----------------------------------------------------------------------

No, the issue can occur only for values which are amended during clamping, So the issue is present only for values that are not not in possible INTEGER interval


was (Author: jooger):
No, the issue can occur only for values which are amended during glamping, So the issue is present only for values that are not not in possible INTEGER interval

> SUBSTRING can return incorrect empty result for some parameters
> ---------------------------------------------------------------
>
>                 Key: CALCITE-6433
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6433
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.37.0
>            Reporter: Iurii Gerzhedovich
>            Priority: Major
>
> SUBSTRING function for cases when 3rd parameter (length) more than
> Integer.MAX_VALUE can return empty result due to code do clamp
>  that value and after that it can't be more than Integer.MAX_VALUE.
> Simple way to reproduce :
> append into *SqlOperatorTest* smth like:
> {noformat}
>     f.checkScalar(
>         String.format("{fn SUBSTRING('abcdef', %d, %d)}", Integer.MIN_VALUE, 10L + Integer.MAX_VALUE),
>         "abcdef",
>         "VARCHAR(6) NOT NULL");
> {noformat}
> it`s all due to check after clamping
> {noformat}
> public static String substring(String c, int s, int l) {
>   ....
>   long e = (long) s + (long) l; -- here we can got incorrect length 
>   .....
>   if (s > lc || e < 1L) {
>     return "";
>   }
> .....{noformat}
>  
>  



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