tprelle commented on a change in pull request #31639:
URL: https://github.com/apache/spark/pull/31639#discussion_r583264905
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
##########
@@ -874,13 +874,29 @@ class SessionCatalog(
// the extra columns that we don't require), with UpCast (to make sure the
type change is
// safe) and Alias (to respect user-specified view column names) according
to the view schema
// in the catalog.
- val projectList = viewColumnNames.zip(metadata.schema).map { case (name,
field) =>
- Alias(UpCast(UnresolvedAttribute.quoted(name), field.dataType),
field.name)(
- explicitMetadata = Some(field.metadata))
+ val projectList = if (isTempView) {
+ viewColumnNames.zip(metadata.schema).map { case (name, field) =>
+ Alias(UpCast(UnresolvedAttribute.quoted(name), field.dataType),
field.name)(
+ explicitMetadata = Some(field.metadata))
+ }
+ } else {
+ viewColumnNames.zip(metadata.schema).
+ map { case (name, field) => innerStruct(Seq(), name, field)}
}
View(desc = metadata, isTempView = isTempView, child =
Project(projectList, parsedPlan))
}
+ private def innerStruct(parent : Seq[String], name : String,
+ field : StructField) : NamedExpression = {
+ field.dataType match {
+ case structType : StructType => Alias(CreateStruct.create(structType.map
{
Review comment:
Maybe but i dit not know if this making a huge difference, and i do not
found a way to check at this moment of the analysis of the code if the
references table is altered or not.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]