[
https://issues.apache.org/jira/browse/CALCITE-7499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077954#comment-18077954
]
Mihai Budiu commented on CALCITE-7499:
--------------------------------------
I think the issue as filed is misleading: it suggests that type inference or
type coercion for COALESCE is wrong, but what seems to be wrong is
simplification of COALESCE.
> COALESCE doesn't take into account leastRestrictiveType for input args
> ----------------------------------------------------------------------
>
> Key: CALCITE-7499
> URL: https://issues.apache.org/jira/browse/CALCITE-7499
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Sergey Nuyanzin
> Assignee: Sergey Nuyanzin
> Priority: Major
> Labels: pull-request-available
>
> In case {{COALESCE}} has at least 2 args as input of different types (e.g.
> INT and BIGINT) like
> {code:sql}
> SELECT COALESCE(1, CAST(1 AS BIGINT));
> {code}
> it returns 1 as INT while {{leastRestrictiveType}} is BIGINT.
> Similar issue for other types and for types with different precision.
> Postgres takes into account types of input args
> https://onecompiler.com/postgresql/44n48bnc8
> also MySql https://onecompiler.com/mysql/44n4cgk4q
--
This message was sent by Atlassian Jira
(v8.20.10#820010)