Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/15266#discussion_r81465775
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
---
@@ -159,8 +159,9 @@ case class DataSourceAnalysis(conf: CatalystConf)
extends Rule[LogicalPlan] {
case i @ logical.InsertIntoTable(
- l @ LogicalRelation(t: HadoopFsRelation, _, _), part, query,
overwrite, false)
- if query.resolved && t.schema.asNullable ==
query.schema.asNullable =>
--- End diff --
Did an investigation. For the struct type, we store the nested schema in
the data type. Thus, after we cast the data type of struct, we also copy the
schema at the same time.
Below is the explained plan of the example I just added.
```
== Analyzed Logical Plan ==
InsertIntoHadoopFsRelationCommand
file:/Users/xiaoli/IdeaProjects/sparkDelivery/spark-warehouse/tab2,
ParquetFormat, <function0>, Map(path ->
file:/Users/xiaoli/IdeaProjects/sparkDelivery/spark-warehouse/tab2), Append
+- Project [cast(s#36 as struct<c:string,d:string>) AS p#40]
+- Project [s#36]
+- SubqueryAlias tab1
+- Relation[s#36] parquet
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]