You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "fqaiser94 (Jira)" <ji...@apache.org> on 2020/08/17 20:53:00 UTC

[jira] [Created] (SPARK-32641) withField + getField on null structs returns incorrect results

fqaiser94 created SPARK-32641:
---------------------------------

             Summary: withField + getField on null structs returns incorrect results
                 Key: SPARK-32641
                 URL: https://issues.apache.org/jira/browse/SPARK-32641
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.1.0
            Reporter: fqaiser94


 

There is a bug in the way the optimizer rule in SimplifyExtractValueOps (sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ComplexTypes.scala) is currently coded which yields incorrect results in scenarios like the following: 
{code:java}
sql("SELECT CAST(NULL AS struct<a:int,b:int>) struct_col")
.select($"struct_col".withField("d", lit(4)).getField("d").as("d"))

// currently returns this:
+---+
|d  |
+---+
|4  |
+---+

// when in fact it should return this: 
+----+
|d   |
+----+
|null|
+----+
{code}
 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org