You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ran Tao (Jira)" <ji...@apache.org> on 2023/10/12 09:06:00 UTC
[jira] [Comment Edited] (CALCITE-6040) The operand type inference of SqlMapValueConstructor is incorrect
[ https://issues.apache.org/jira/browse/CALCITE-6040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17774381#comment-17774381 ]
Ran Tao edited comment on CALCITE-6040 at 10/12/23 9:05 AM:
------------------------------------------------------------
The PR is ready: [https://github.com/apache/calcite/pull/3463, |https://github.com/apache/calcite/pull/3463]maybe we can add this fix in 1.36.0.
If someone has time, please help me to review it, thanks a lot.
was (Author: lemonjing):
The PR is ready: https://github.com/apache/calcite/pull/3463
If someone has time, please help me to review it, thanks a lot.
> The operand type inference of SqlMapValueConstructor is incorrect
> -----------------------------------------------------------------
>
> Key: CALCITE-6040
> URL: https://issues.apache.org/jira/browse/CALCITE-6040
> Project: Calcite
> Issue Type: Bug
> Components: tests
> Affects Versions: 1.35.0
> Reporter: Ran Tao
> Assignee: Ran Tao
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.36.0
>
>
> we have a simple test case:
> {code:java}
> f.checkScalar("map[1, null]", "{1=null}",
> "(INTEGER NOT NULL, NULL) MAP NOT NULL"); {code}
> The result is:
> {noformat}
> java.lang.AssertionError: Query: values (map[1, null])
> Expected: is "(INTEGER NOT NULL, NULL) MAP NOT NULL"
> but: was "(INTEGER NOT NULL, INTEGER) MAP NOT NULL"
> {noformat}
> however, the asserted actual result "(INTEGER NOT NULL, INTEGER) MAP NOT NULL" for this case is wrong. If we switch to this asserted actual result it throws another exception:
> {noformat}
> java.lang.AssertionError: Query: select map[p0, null] from (values (1)) as t(p0)
> Expected: is "(INTEGER NOT NULL, INTEGER) MAP NOT NULL"
> but: was "(INTEGER NOT NULL, NULL) MAP NOT NULL"
> {noformat}
> No matter how you write this result type in this test case, it is wrong.
> by checking the plan, it seems the deduced value type of NULL has converted to INTEGER.
> More serious scenario, if it is `map[1, 'x', 2, null]`, an exception will be thrown directly and fail.
> because the null converted to FIRST_KNOWN INTEGER(however it should keep NULL, then leaseRestrictive type will be char). the `map[1, null, 2,'x']` has same problem.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)