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

Maksim Zhuravkov updated IGNITE-18831:
--------------------------------------
    Description: 
At the moment the execution runtime is not aware of dynamic parameter types 
inferred at the validation stage and when the validation stage completes those 
types are thrown away. During the execution, the runtime uses the _java_class_ 
of a type parameter to perform an operation, which fails in the following case:

A query has a dynamic parameter (string) but the validator, by using implicit 
cast rules inferred, the actual type for that dynamic parameter to be some 
another type that can be implicitly created from a string. 

{code:java}
CREATE TABLE UUIDS (id INTEGER PRIMARY KEY, uuid_key UUID);
INSERT INTO UUIDS VALUES(1, ?);
{code}

* Execution runtime loses type information of the dynamic parameter and assumes 
it to be a string. 
* At the runtime toInternal call is going to fail, because it expects the type 
of this parameter to be UUID but dynamic parameter contains a string.

*Solution*

Use Sql-based RelDataTypes for parameter types and pass them among with 
parameters to the execution runtime.

We should use Sql-based RelDataTypes instead of JavaDataTypes, because the 
latter are always nullable and that may cause the optimizer to choose a 
suboptimal plan.





  was:
At the moment the execution runtime is not aware of dynamic parameter types 
inferred at the validation stage and when the validation stage completes those 
types are thrown away. During the execution, the runtime uses the _java_class_ 
of a type parameter to perform an operation, which fails in the following case:

A query has a dynamic parameter (string) but the validator, by using implicit 
cast rules inferred, the actual type for that dynamic parameter to be some 
another type that can be implicitly created from a string. 

{code:java}
CREATE TABLE UUIDS (id INTEGER PRIMARY KEY, uuid_key UUID);
INSERT INTO UUIDS VALUES(1, ?);
{code}

* Execution runtime loses type information of the dynamic parameter and assumes 
it to be a string. 
* At the runtime toInternal call is going to fail, because it expects the type 
of this parameter to be UUID but dynamic parameter contains a string.

*Solution*

Use Sql-based RelDataTypes for parameter types and pass them among with 
parameters to the execution runtime.

We should use Sql-based RelDataTypes instead of JavaDataTypes because the 
latter are always nullable, and that in may cause the optimizer to choose a 
suboptimal plan.






> Sql. Dynamic parameters. Inferred types of dynamic parameters are not used by 
> the execution runtime.
> ----------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-18831
>                 URL: https://issues.apache.org/jira/browse/IGNITE-18831
>             Project: Ignite
>          Issue Type: Improvement
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Minor
>              Labels: calcite2-required, calcite3-required, ignite-3
>             Fix For: 3.0.0-beta2
>
>
> At the moment the execution runtime is not aware of dynamic parameter types 
> inferred at the validation stage and when the validation stage completes 
> those types are thrown away. During the execution, the runtime uses the 
> _java_class_ of a type parameter to perform an operation, which fails in the 
> following case:
> A query has a dynamic parameter (string) but the validator, by using implicit 
> cast rules inferred, the actual type for that dynamic parameter to be some 
> another type that can be implicitly created from a string. 
> {code:java}
> CREATE TABLE UUIDS (id INTEGER PRIMARY KEY, uuid_key UUID);
> INSERT INTO UUIDS VALUES(1, ?);
> {code}
> * Execution runtime loses type information of the dynamic parameter and 
> assumes it to be a string. 
> * At the runtime toInternal call is going to fail, because it expects the 
> type of this parameter to be UUID but dynamic parameter contains a string.
> *Solution*
> Use Sql-based RelDataTypes for parameter types and pass them among with 
> parameters to the execution runtime.
> We should use Sql-based RelDataTypes instead of JavaDataTypes, because the 
> latter are always nullable and that may cause the optimizer to choose a 
> suboptimal plan.



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

Reply via email to