beliefer commented on code in PR #37251:
URL: https://github.com/apache/spark/pull/37251#discussion_r927410158


##########
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:
   `Alias` could inherit metadata from child.



-- 
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]

Reply via email to