[ 
https://issues.apache.org/jira/browse/CALCITE-6522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Caican Cai updated CALCITE-6522:
--------------------------------
    Summary: MAP_KEYS and MAP_VALUES function should throw if a key value is 
null  (was: MAP_KEYS and MAP_VALUES   function should throw if a key value is 
null)

> MAP_KEYS and MAP_VALUES function should throw if a key value is null
> --------------------------------------------------------------------
>
>                 Key: CALCITE-6522
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6522
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.37.0
>            Reporter: Caican Cai
>            Assignee: Caican Cai
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.38.0
>
>
> scala> val df = spark.sql("select map_keys(map(null,0))");
> df: org.apache.spark.sql.DataFrame = [map_keys(map(NULL, 0)): array<void>]
> scala> df.show();
> org.apache.spark.SparkRuntimeException: [NULL_MAP_KEY] Cannot use null as map 
> key.
>   at 
> org.apache.spark.sql.errors.QueryExecutionErrors$.nullAsMapKeyNotAllowedError(QueryExecutionErrors.scala:445)
>   at 
> org.apache.spark.sql.catalyst.util.ArrayBasedMapBuilder.put(ArrayBasedMapBuilder.scala:56)
>   at 
> org.apache.spark.sql.catalyst.expressions.CreateMap.eval(complexTypeCreator.scala:248)
> scala> val df = spark.sql("select map_values(map(cast(null as int),0, 'foo', 
> 1))");
> df: org.apache.spark.sql.DataFrame = [map_values(map(CAST(NULL AS INT), 0, 
> foo, 1)): array<int>]
> scala> df.show()
> org.apache.spark.SparkRuntimeException: [NULL_MAP_KEY] Cannot use null as map 
> key.
>   at 
> org.apache.spark.sql.errors.QueryExecutionErrors$.nullAsMapKeyNotAllowedError(QueryExecutionErrors.scala:445)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to