From 91372e4d2715c38843b45ca60bbc055ca9f7870c Mon Sep 17 00:00:00 2001 From: ashahid Date: Tue, 17 Sep 2024 10:39:44 -0700 Subject: [PATCH] SPARK-49618. Using Seq of legs to get hashCode instead of Set --- .../org/apache/spark/sql/catalyst/plans/UnionEquality.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/UnionEquality.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/UnionEquality.scala index 3e17cd3285ef4..1ed6aba7763c4 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/UnionEquality.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/UnionEquality.scala @@ -19,12 +19,16 @@ package org.apache.spark.sql.catalyst.plans import scala.collection.mutable +import com.google.common.base.Objects + import org.apache.spark.sql.catalyst.expressions.{Attribute, ExprId} trait UnionEquality [PlanType <: QueryPlan[PlanType]] { self: PlanType => - private lazy val positionAgnosticHash = this.children.toSet.hashCode() + // because union legs can have repeats, avoiding this.children.toSet.hashCode + private lazy val positionAgnosticHash = + Objects.hashCode(this.children.map(_.hashCode()).sorted: _*) // for now should be used only for unionAll. Union distinct may not have size check def positionAgnosticEquals(that: PlanType): Boolean = {