This is an automated email from the ASF dual-hosted git repository. yao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new f462b6319af [SPARK-43979][SQL][FOLLOWUP] Fix the detection of alias-only project f462b6319af is described below commit f462b6319afc3a1fb8b0c4c9ab6c49e79167bdbc Author: Wenchen Fan <wenc...@databricks.com> AuthorDate: Sat Aug 12 00:38:32 2023 +0800 [SPARK-43979][SQL][FOLLOWUP] Fix the detection of alias-only project ### What changes were proposed in this pull request? Fix a minor mistake in https://github.com/apache/spark/pull/42408 which is found during the branch 3.5 backport. https://github.com/apache/spark/pull/42449 fixed it `branch-3.5` first. ### Why are the changes needed? To make the code align with 3.5. We may remove `simplifyPlanForCollectedMetrics` entirely as it seems not an issue anymore in the master branch due to how we deduplicate relations. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? existing tests Closes #42453 from cloud-fan/minor. Authored-by: Wenchen Fan <wenc...@databricks.com> Signed-off-by: Kent Yao <y...@apache.org> --- .../org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala index 0b953fc2b61..48c38a9bd4c 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala @@ -1113,9 +1113,12 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB private def simplifyPlanForCollectedMetrics(plan: LogicalPlan): LogicalPlan = { plan.resolveOperators { case p: Project if p.projectList.size == p.child.output.size => - val assignExprIdOnly = p.projectList.zip(p.child.output).forall { - case (left: Alias, right: Attribute) => - left.child.semanticEquals(right) && right.name == left.name + val assignExprIdOnly = p.projectList.zipWithIndex.forall { + case (Alias(attr: AttributeReference, _), index) => + // The input plan of this method is already canonicalized. The attribute id becomes the + // ordinal of this attribute in the child outputs. So an alias-only Project means the + // the id of the aliased attribute is the same as its index in the project list. + attr.exprId.id == index case _ => false } if (assignExprIdOnly) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org