[ 
https://issues.apache.org/jira/browse/SPARK-42899?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hyukjin Kwon resolved SPARK-42899.
----------------------------------
    Fix Version/s: 3.4.1
         Assignee: Takuya Ueshin
       Resolution: Fixed

Fixed in https://github.com/apache/spark/pull/40526

> DataFrame.to(schema) fails when it contains non-nullable nested field in 
> nullable field
> ---------------------------------------------------------------------------------------
>
>                 Key: SPARK-42899
>                 URL: https://issues.apache.org/jira/browse/SPARK-42899
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.4.0
>            Reporter: Takuya Ueshin
>            Assignee: Takuya Ueshin
>            Priority: Major
>             Fix For: 3.4.1
>
>
> {{DataFrame.to(schema)}} fails when it contains non-nullable nested field in 
> nullable field:
> {code:scala}
> scala> val df = spark.sql("VALUES (1, STRUCT(1 as i)), (NULL, NULL) as t(a, 
> b)")
> df: org.apache.spark.sql.DataFrame = [a: int, b: struct<i: int>]
> scala> df.printSchema()
> root
>  |-- a: integer (nullable = true)
>  |-- b: struct (nullable = true)
>  |    |-- i: integer (nullable = false)
> scala> df.to(df.schema)
> org.apache.spark.sql.AnalysisException: [NULLABLE_COLUMN_OR_FIELD] Column or 
> field `b`.`i` is nullable while it's required to be non-nullable.
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to