[
https://issues.apache.org/jira/browse/CALCITE-7528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081408#comment-18081408
]
Zhen Chen commented on CALCITE-7528:
------------------------------------
I've verified with Hive that it does support NULL as a key, so I'll close JIRA
now. I believe Calcite should be the union of all databases.
{code:java}
0: jdbc:hive2://localhost:10000> SELECT map('a', 1, NULL, 2);
INFO : Compiling
command(queryId=hive_20260516150808_85211af1-ab2e-4439-86f4-1e8f7c1cebcd):
SELECT map('a', 1, NULL, 2) INFO :
Semantic Analysis Completed (retrial = false)
INFO
: Created Hive schema: Schema(fieldSchemas:[FieldSchema(name:_c0, type:map,
comment:null)], properties:null) INFO :
Completed compiling
command(queryId=hive_20260516150808_85211af1-ab2e-4439-86f4-1e8f7c1cebcd); Time
taken: 0.053 seconds INFO : Concurrency mode
is disabled, not creating a lock manager
INFO : Executing
command(queryId=hive_20260516150808_85211af1-ab2e-4439-86f4-1e8f7c1cebcd):
SELECT map('a', 1, NULL, 2) INFO :
Completed executing
command(queryId=hive_20260516150808_85211af1-ab2e-4439-86f4-1e8f7c1cebcd); Time
taken: 0.0 seconds +-----------------+
| _c0 |
+-----------------+
| {"a":1,null:2} |
+-----------------+
1 row selected (0.064 seconds) {code}
> 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)