Skip to content

Commit

Permalink
[SPARK-22326][SQL] Remove unnecessary hashCode and equals methods
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?

Plan equality should be computed by `canonicalized`, so we can remove unnecessary `hashCode` and `equals` methods.

## How was this patch tested?

Existing tests.

Author: Zhenhua Wang <wangzhenhua@huawei.com>

Closes #19539 from wzhfy/remove_equals.
  • Loading branch information
wzhfy authored and gatorsmile committed Oct 21, 2017
1 parent b8624b0 commit d9f286d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import java.util.Date

import scala.collection.mutable

import com.google.common.base.Objects

import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.{FunctionIdentifier, InternalRow, TableIdentifier}
import org.apache.spark.sql.catalyst.analysis.MultiInstanceRelation
Expand Down Expand Up @@ -440,15 +438,6 @@ case class HiveTableRelation(

def isPartitioned: Boolean = partitionCols.nonEmpty

override def equals(relation: Any): Boolean = relation match {
case other: HiveTableRelation => tableMeta == other.tableMeta && output == other.output
case _ => false
}

override def hashCode(): Int = {
Objects.hashCode(tableMeta.identifier, output)
}

override lazy val canonicalized: HiveTableRelation = copy(
tableMeta = tableMeta.copy(
storage = CatalogStorageFormat.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ case class LogicalRelation(
override val isStreaming: Boolean)
extends LeafNode with MultiInstanceRelation {

// Logical Relations are distinct if they have different output for the sake of transformations.
override def equals(other: Any): Boolean = other match {
case l @ LogicalRelation(otherRelation, _, _, isStreaming) =>
relation == otherRelation && output == l.output && isStreaming == l.isStreaming
case _ => false
}

override def hashCode: Int = {
com.google.common.base.Objects.hashCode(relation, output)
}

// Only care about relation when canonicalizing.
override lazy val canonicalized: LogicalPlan = copy(
output = output.map(QueryPlan.normalizeExprId(_, output)),
Expand Down

0 comments on commit d9f286d

Please sign in to comment.