[ 
https://issues.apache.org/jira/browse/CALCITE-7528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081024#comment-18081024
 ] 

Julian Hyde commented on CALCITE-7528:
--------------------------------------

According to Gemini, Hive is the only database (other than Calcite) that allows 
nulls. I don't feel strongly about this, but I would be happy if we did 
nothing. I suspect that databases such as Spark that disallow nulls are more 
strongly influenced by their JVM-based implementation than by a consideration 
of what would be idiomatic SQL behavior.

> 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)

Reply via email to