MaxGekk 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_r377753061
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/DataFrameFunctionsSuite.scala
 ##########
 @@ -3499,11 +3499,17 @@ class DataFrameFunctionsSuite extends QueryTest with 
SharedSparkSession {
     ).foreach(assertValuesDoNotChangeAfterCoalesceOrUnion(_))
   }
 
-  test("SPARK-21281 use string types by default if map have no argument") {
-    val ds = spark.range(1)
-    var expectedSchema = new StructType()
-      .add("x", MapType(StringType, StringType, valueContainsNull = false), 
nullable = false)
-    assert(ds.select(map().as("x")).schema == expectedSchema)
+  test("SPARK-30790: Empty map of <NullType,NullType> for map function with no 
arguments") {
+    Seq((true, StringType), (false, NullType)).foreach {
+      case (mapDefaultToString, expectedType) =>
+        withSQLConf(SQLConf.LEGACY_MAP_DEFAULT_TO_STRING.key -> 
mapDefaultToString.toString) {
+          val schema = spark.range(1).select(map()).schema
+          assert(schema.nonEmpty && schema.head.dataType.isInstanceOf[MapType])
+          val actualKeyType = 
schema.head.dataType.asInstanceOf[MapType].keyType
+          val actualValueType = 
schema.head.dataType.asInstanceOf[MapType].valueType
+          assert(actualKeyType === expectedType && actualValueType === 
expectedType)
 
 Review comment:
   nit:
   ```scala
       val schema = spark.range(1).select(map()).schema
       val StructType(Array(StructField(_, MapType(keyType, valueType, _), _, 
_))) = schema
       assert(keyType === expectedType)
       assert(valueType === expectedType)
   ```

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

Reply via email to