[ 
https://issues.apache.org/jira/browse/SPARK-32167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17151392#comment-17151392
 ] 

Dongjoon Hyun edited comment on SPARK-32167 at 7/4/20, 6:20 PM:
----------------------------------------------------------------

After looking at the code, I realize that this is a very old code path from 
1.5.0 or older. This should be the following and 2.3.4 and older also have this 
bug.
{code:java}
scala> df.select($"arr".getField("i")).printSchema
root
 |-- arr.i: array (nullable = true)
 |    |-- element: integer (containsNull = true){code}


was (Author: dongjoon):
After looking at the code, I realize that this is a very old code path from 
1.5.0. This should be the following and 2.3.4 and older also have this bug.
{code:java}
scala> df.select($"arr".getField("i")).printSchema
root
 |-- arr.i: array (nullable = true)
 |    |-- element: integer (containsNull = true){code}

> nullability of GetArrayStructFields is incorrect
> ------------------------------------------------
>
>                 Key: SPARK-32167
>                 URL: https://issues.apache.org/jira/browse/SPARK-32167
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.6.3, 2.0.2, 2.1.3, 2.2.3, 2.3.4, 2.4.6, 3.0.0
>            Reporter: Wenchen Fan
>            Assignee: Wenchen Fan
>            Priority: Blocker
>              Labels: correctness
>
> The following should be `Array([WrappedArray(1, null)])` instead of 
> `Array([WrappedArray(1, 0)])`
> {code:java}
> import scala.collection.JavaConverters._
> import org.apache.spark.sql.Row
> import org.apache.spark.sql.types.{ArrayType, StructType}
> val innerStruct = new StructType().add("i", "int", nullable = true)
> val schema = new StructType().add("arr", ArrayType(innerStruct, containsNull 
> = false))
> val df = spark.createDataFrame(List(Row(Seq(Row(1), Row(null)))).asJava, 
> schema)
> df.select($"arr".getField("i")).collect
> {code}
>  



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

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

Reply via email to