mihailotim-db commented on code in PR #50304: URL: https://github.com/apache/spark/pull/50304#discussion_r2002998037
########## 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: I don't think that is semantically correct and it's possibly even wrong. I think with lazy compilation it is possible to have something like Project[a, b, c] -> Project[a, b] -> Project[a] and some sort of `Join` below where b and c would be metadata columns. In that case the inner-most project would lose information that it needs c and wouldn't add it. I think this is a much safer change than that and easier to guard under a flag -- 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