[
https://issues.apache.org/jira/browse/CALCITE-7528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081019#comment-18081019
]
Zhen Chen commented on CALCITE-7528:
------------------------------------
Hi [~julianhyde] , The format of my previous verification was incorrect. When I
was verifying it, I found that DuckDB also rejected cases where the key was
NULL.
> Reject NULL keys in MAP
> -----------------------
>
> Key: CALCITE-7528
> URL: https://issues.apache.org/jira/browse/CALCITE-7528
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Zhen Chen
> Priority: Major
>
> Calcite currently allows {{NULL}} to be used as a key in {{MAP}} literals,
> but this behavior is inconsistent with major database systems and query
> engines, which uniformly reject {{NULL}} as a map key.
> This leads to portability issues and semantic ambiguity in SQL compatibility
> mode.
> h3. pected Behavior (based on mainstream engines)
> {code:java}
> # clickhouse
> SELECT map('a', 1, NULL, 2);
> Error: Map cannot have a key of type Nullable(String): In scope SELECT
> map('a', 1, NULL, 2).
> # duckdb
> SELECT MAP{'a': 1, NULL: 2};
> Invalid Input Error:
> Map keys can not be NULL.
> # datafusion
> SELECT MAP{'a': 1, NULL: 2};
> Execution error: map key cannot be null
> # spark
> SELECT map('a', 1, NULL, 2);
> [NULL_MAP_KEY] Cannot use null as map key. SQLSTATE: 2200E
> org.apache.spark.SparkRuntimeException: [NULL_MAP_KEY] Cannot use null as map
> key. SQLSTATE: 2200E {code}
> *Reproduction Example*
> {code:java}
> SELECT MAP['a', 1, NULL, 2];
> EXPR$0 {a=1, null=2}
> !ok {code}
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)