You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Caican Cai (Jira)" <ji...@apache.org> on 2024/05/03 15:41:00 UTC
[jira] [Comment Edited] (CALCITE-6352) The map_contains_key function may return true when the key and mapkeytype types are different.
[ https://issues.apache.org/jira/browse/CALCITE-6352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17843235#comment-17843235 ]
Caican Cai edited comment on CALCITE-6352 at 5/3/24 3:40 PM:
-------------------------------------------------------------
{code:java}
scala> val df = spark.sql("select map_contains_key(map(1, 'a', 2.0, 'b'), 2)")
df: org.apache.spark.sql.DataFrame = [map_contains_key(map(1, a, 2.0, b), 2): boolean]scala> df.show()
+--------------------------------------+
|map_contains_key(map(1, a, 2.0, b), 2)|
+--------------------------------------+
| true|
+--------------------------------------+
scala> val df = spark.sql("select map_contains_key(map(1, 'a', 2.0, 'b'), 2f)")
df: org.apache.spark.sql.DataFrame = [map_contains_key(map(1, a, 2.0, b), 2.0): boolean]scala> df.show()
+----------------------------------------+
|map_contains_key(map(1, a, 2.0, b), 2.0)|
+----------------------------------------+
| true|
+----------------------------------------+
{code}
[~mbudiu] Hello, It seems that as long as the numbers are the same, true can be returned, regardless of whether the number type is double, int, or float.
i submit a pr
was (Author: JIRAUSER302115):
{code:java}
scala> val df = spark.sql("select map_contains_key(map(1, 'a', 2.0, 'b'), 2)")
df: org.apache.spark.sql.DataFrame = [map_contains_key(map(1, a, 2.0, b), 2): boolean]scala> df.show()
+--------------------------------------+
|map_contains_key(map(1, a, 2.0, b), 2)|
+--------------------------------------+
| true|
+--------------------------------------+
scala> val df = spark.sql("select map_contains_key(map(1, 'a', 2.0, 'b'), 2f)")
df: org.apache.spark.sql.DataFrame = [map_contains_key(map(1, a, 2.0, b), 2.0): boolean]scala> df.show()
+----------------------------------------+
|map_contains_key(map(1, a, 2.0, b), 2.0)|
+----------------------------------------+
| true|
+----------------------------------------+
{code}
[~mbudiu] Hello, It seems that as long as the numbers are the same, true can be returned, regardless of whether the number type is double, int, or float.
> The map_contains_key function may return true when the key and mapkeytype types are different.
> ----------------------------------------------------------------------------------------------
>
> Key: CALCITE-6352
> URL: https://issues.apache.org/jira/browse/CALCITE-6352
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.36.0
> Reporter: Caican Cai
> Assignee: Caican Cai
> Priority: Critical
> Labels: pull-request-available
> Fix For: 1.37.0
>
>
>
> {code:java}
> scala> val df = spark.sql("select map_contains_key(map(1, 'a', 2, 'b'), 2.0)")
> val df: org.apache.spark.sql.DataFrame = [map_contains_key(map(1, a, 2, b), 2.0): boolean]
> scala> df.show()
> +--------------------------------------+
> |map_contains_key(map(1, a, 2, b), 2.0)|
> +--------------------------------------+
> | true|
> +--------------------------------------+
> {code}
> calcite return false
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)