mihailotim-db commented on code in PR #50304: URL: https://github.com/apache/spark/pull/50304#discussion_r2002687619
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala: ########## @@ -1031,18 +1036,39 @@ class Analyzer(override val catalogManager: CatalogManager) extends RuleExecutor private def addMetadataCol( plan: LogicalPlan, - requiredAttrIds: Set[ExprId]): LogicalPlan = plan match { + requiredAttrIds: Set[ExprId], + onlyUniqueAndNecessaryMetadataColumns: Boolean = true): LogicalPlan = plan match { case s: ExposesMetadataColumns if s.metadataOutput.exists( a => requiredAttrIds.contains(a.exprId)) => s.withMetadataColumns() case p: Project if p.metadataOutput.exists(a => requiredAttrIds.contains(a.exprId)) => + val existingExprIds = new util.HashSet[ExprId] + p.projectList.foreach(attr => existingExprIds.add(attr.exprId)) Review Comment: That's the caveat of `AddMetadataColumns`. `requiredAttrIds` is computed between entry point node and its child. But those missing attributes are then added to ALL nodes below regardless of whether or not they already have these attributes. For the case of entry node and its direct child, this part should be no-op -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org