kupferk commented on code in PR #37251:
URL: https://github.com/apache/spark/pull/37251#discussion_r927412109
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/CollapseProjectSuite.scala:
##########
@@ -223,6 +224,24 @@ class CollapseProjectSuite extends PlanTest {
assert(hasMetadata(optimized))
}
+ test("reset top-level alias metadata while collapsing projects") {
+ def hasNoMetadata(logicalPlan: LogicalPlan): Boolean = {
+
!logicalPlan.asInstanceOf[Project].projectList.exists(_.metadata.contains("key"))
+ }
+
+ val metadata = new MetadataBuilder().putLong("key", 1).build()
+ val analyzed =
+ Project(Seq(Alias('a_with_metadata, "b")(explicitMetadata =
Some(Metadata.empty))),
+ Project(Seq(Alias('a, "a_with_metadata")(explicitMetadata =
Some(metadata))),
+ testRelation.logicalPlan)).analyze
+ require(hasNoMetadata(analyzed))
Review Comment:
In my understanding, inheriting metadata is not intended if explicit
metadata is provided. At least this was the case up until Spark 3.2.x.
Unpatched Spark 3.3 will also replace the existing childs metadata, if the
newly provided metadata is not empty. Only the case when providing an empty
metadata does not work as I expect.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]