You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Konstantin Orlov (Jira)" <ji...@apache.org> on 2024/10/16 11:20:00 UTC

[jira] [Resolved] (IGNITE-22358) Sql. Results of TypeFactory::leastRestrictiveType are incompatible with legal type transformations

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

Konstantin Orlov resolved IGNITE-22358.
---------------------------------------
    Resolution: Fixed

> Sql. Results of TypeFactory::leastRestrictiveType are incompatible with legal type transformations
> --------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-22358
>                 URL: https://issues.apache.org/jira/browse/IGNITE-22358
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>             Fix For: 3.0
>
>
> {noformat}
> SELECT 1 UNION ALL SELECT '2000-01-01'::DATE
> # returns: DATE, DATE
> {noformat}
> Although a cast from INT to DATE should not be possible according to type transformation rules:
> {noformat}
> SELECT 1::DATE 
> # Error: Cast function cannot convert value of type INTEGER to type DATE
> {noformat}
> This query should also return an error because it is not possible to convert an integer into a date.
> This happens because Calcite's SqlTypeFactoryImpl::leastRestrictiveSqlType contains explicit code that allows int to date conversion and that code completely ignores Calcite's TypeConversion rules.
> {code:java}
>  else if (SqlTypeUtil.isExactNumeric(type)) {
>         if (SqlTypeUtil.isExactNumeric(resultType)) {
>           // TODO: come up with a cleaner way to support
>           // interval + datetime = datetime
>           if (types.size() > (i + 1)) {
>             RelDataType type1 = types.get(i + 1);
>             if (SqlTypeUtil.isDatetime(type1)) {
>               resultType = type1;
>               return createTypeWithNullability(resultType,
>                   nullCount > 0 || nullableCount > 0);
>             }
>           }
> {code}



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