iRakson commented on a change in pull request #27542: [SPARK-30790]The dataType
of map() should be map<null,null>
URL: https://github.com/apache/spark/pull/27542#discussion_r378099765
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala
##########
@@ -167,9 +175,9 @@ case class CreateMap(children: Seq[Expression]) extends
Expression {
override lazy val dataType: MapType = {
MapType(
keyType =
TypeCoercion.findCommonTypeDifferentOnlyInNullFlags(keys.map(_.dataType))
- .getOrElse(StringType),
+ .getOrElse(defaultElementType),
Review comment:
In `ArrayBaseMapBuilder`, we have handled `Nulltype` for key. This causes
following problem:
```
scala> sql("select map(null,2)")
res1: org.apache.spark.sql.DataFrame = [map(NULL, 2): map<null,int>]
scala> sql("select map(null,2)").collect
scala.MatchError: NullType (of class org.apache.spark.sql.types.NullType$)
at
org.apache.spark.sql.catalyst.util.TypeUtils$.getInterpretedOrdering(TypeUtils.scala:67)
at
org.apache.spark.sql.catalyst.util.ArrayBasedMapBuilder.keyToIndex$lzycompute(ArrayBasedMapBuilder.scala:37)
```
After removing the assertion we need to handle this problem.
@cloud-fan
[#23124(comment)](https://github.com/apache/spark/pull/23124/commits/9df627465d9f9bcdde129baf1304035f082e5ab6?file-filters%5B%5D=.scala#r235929748)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]