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

Evgeny Stanilovsky updated IGNITE-21035:
----------------------------------------
    Fix Version/s: 3.2
                       (was: 3.1)

> Sql. Fix type inference for dynamic parameters in operators.
> ------------------------------------------------------------
>
>                 Key: IGNITE-21035
>                 URL: https://issues.apache.org/jira/browse/IGNITE-21035
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>             Fix For: 3.2
>
>
> Dynamic parameters used in operators require additional type casts to work 
> properly, since calcite's type checkers use type families that consist of 
> multiple types. 
> Several examples:
> {code:java}
> // val is VARCHAR
> INSERT INTO t1 (val, id) SELECT ? || 'asd', ?
> // Error:
> org.apache.ignite.sql.SqlException: IGN-SQL-6 
> TraceId:557e7c5d-6a7a-4e3f-ba1f-e095c662f675 Failed to validate query. From 
> line 1, column 33 to line 1, column 42: Ambiguous operator ||(<UNKNOWN>, 
> <CHAR(3)>). Dynamic parameter requires adding explicit type cast. Supported 
> form(s): 
> '<STRING> || <STRING>'
> '<EQUIVALENT_TYPE> || <EQUIVALENT_TYPE>'
> {code}
> Function call (INTEGER is a type family):
> {code:java}
> "SELECT substring('asd', ?) FROM t1"
> org.apache.ignite.sql.SqlException: IGN-SQL-6 
> TraceId:a2a35703-34e6-447f-aebd-bbd5f070eaa2 Failed to validate query. From 
> line 1, column 8 to line 1, column 26: Ambiguous operator 
> SUBSTRING(<CHAR(3)>, <UNKNOWN>). Dynamic parameter requires adding explicit 
> type cast. Supported form(s): 
> 'SUBSTRING(<CHAR> FROM <INTEGER>)'
> 'SUBSTRING(<CHAR> FROM <INTEGER> FOR <INTEGER>)'
> 'SUBSTRING(<VARCHAR> FROM <INTEGER>)'
> 'SUBSTRING(<VARCHAR> FROM <INTEGER> FOR <INTEGER>)'
> 'SUBSTRING(<BINARY> FROM <INTEGER>)'
> 'SUBSTRING(<BINARY> FROM <INTEGER> FOR <INTEGER>)'
> 'SUBSTRING(<VARBINARY> FROM <INTEGER>)'
> 'SUBSTRING(<VARBINARY> FROM <INTEGER> FOR <INTEGER>)'
> {code}
> Let's fix this behaviour by selecting the most common type in a type family:
> * For the first case it means that the validator should select use a type of 
> a specified argument, when both arguments are not set it should return an 
> error.
> * In the second example the validator should for the second one it should 
> select an INTEGER type.



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

Reply via email to