Github user liutang123 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21100#discussion_r183005177
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala 
---
    @@ -896,6 +896,19 @@ class SQLQuerySuite extends QueryTest with 
SharedSQLContext {
         }
       }
     
    +  test("SPARK-24012 Union of map and other compatible columns") {
    +    checkAnswer(
    +      sql(
    +        """
    +          |SELECT map(1, 2), 'str'
    +          |UNION ALL
    +          |SELECT map(1, 2, 3, NULL), 1""".stripMargin),
    --- End diff --
    
    Of course we can. 
    two solution:
    1. Try cast two map types to one no matter key types are not the same or 
value types are not the same.
    `select map(1, 2) union all map(1, 'str')` will work.
    2. Cast two map type to one only when the key type and value type are the 
same. This solution just resolve the problem that map<t1, nullable t2> and 
map<t1, not nullable t2> can't be union.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to