You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Zhuravkov (Jira)" <ji...@apache.org> on 2023/04/24 12:19:00 UTC

[jira] [Updated] (IGNITE-19353) Sql. Incorrect type conversion for dynamic parameters - CAST operation ignores type precision.

     [ https://issues.apache.org/jira/browse/IGNITE-19353?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maksim Zhuravkov updated IGNITE-19353:
--------------------------------------
    Description: 
Current implementation of expression execution runtime incorrectly translates types of dynamic parameters because (a) it losses type informations of dynamic parameters (see https://issues.apache.org/jira/browse/IGNITE-18831), (b) it goes against rules of calcite's enumerables/link4j (on which the code is based), which expect dynamic parameters to be converted into their java values according to their inferred types.

The following code illustrates the problem:
{code:java}
 @Test
    public void testReduceLength() {
        assertQuery("SELECT CAST(? AS VARCHAR(2))").withParams("abcd").returns("ab").check();
    }
{code}

The code returns `abcd` when `ab` is expected.

*Solution*: expression execution runtime should use values of dynamic parameters converted to java values according to type information inferred at the validation stage.




  was:
Current implementation of expression execution runtime incorrectly translates types of dynamic parameters because (a) it losses type informations of dynamic parameters (see https://issues.apache.org/jira/browse/IGNITE-18831), (b) it goes against rules of calcite's enumerables/link4j (on which the code is based), which expect dynamic parameters to be converted into their java values according to their inferred types.

The following code illustrates the problem:
{code:java}
 @Test
    public void testReduceLength() {
        assertQuery("SELECT CAST(? AS VARCHAR(2))").withParams("abcd").returns("ab").check();
    }
{code}

The code returns `abcd` when `ab` is expected.

Solution: convert dynamic parameters to java value according their types inferred at the validation stage.





> Sql. Incorrect type conversion for dynamic parameters - CAST operation ignores type precision.
> ----------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-19353
>                 URL: https://issues.apache.org/jira/browse/IGNITE-19353
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>             Fix For: 3.0.0-beta2
>
>
> Current implementation of expression execution runtime incorrectly translates types of dynamic parameters because (a) it losses type informations of dynamic parameters (see https://issues.apache.org/jira/browse/IGNITE-18831), (b) it goes against rules of calcite's enumerables/link4j (on which the code is based), which expect dynamic parameters to be converted into their java values according to their inferred types.
> The following code illustrates the problem:
> {code:java}
>  @Test
>     public void testReduceLength() {
>         assertQuery("SELECT CAST(? AS VARCHAR(2))").withParams("abcd").returns("ab").check();
>     }
> {code}
> The code returns `abcd` when `ab` is expected.
> *Solution*: expression execution runtime should use values of dynamic parameters converted to java values according to type information inferred at the validation stage.



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