Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-42899][SQL] Fix DataFrame.to(schema) to handle the case where …
…there is a non-nullable nested field in a nullable field Fixes `DataFrame.to(schema)` to handle the case where there is a non-nullable nested field in a nullable field. `DataFrame.to(schema)` fails when it contains non-nullable nested field in nullable field: ```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. ``` No. Added the related tests. Closes #40526 from ueshin/issues/SPARK-42899/to_schema. Authored-by: Takuya UESHIN <ueshin@databricks.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org> (cherry picked from commit 4052058) Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
- Loading branch information
1 parent
f73b5c5
commit a1b853c
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters