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

Zhen Chen commented on CALCITE-7528:
------------------------------------

Thanks, [~julianhyde] , for the explanation and suggestion—you are likely right 
about the historical context.

That said, given that DuckDB is written in C++ and DataFusion in Rust, this 
behavior may have effectively become the default standard. It’s also possible 
they are both referencing Spark’s implementation.

Your point regarding Hive allowing NULL keys in MAPs is a strong argument for 
maintaining the status quo. Unless there are further objections, I will mark 
this as 'Won't Fix'.

> 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