Github user JoshRosen commented on a diff in the pull request: https://github.com/apache/spark/pull/13504#discussion_r65807740 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Metadata.scala --- @@ -104,7 +104,8 @@ sealed class Metadata private[types] (private[types] val map: Map[String, Any]) } } - override def hashCode: Int = Metadata.hash(this) + private lazy val _hashCode: Int = Metadata.hash(this) + override def hashCode: Int = _hashCode --- End diff -- Making `hashCode` into a `lazy val` triggers compilation errors and triggers Scalastyle's "You should implement equals and hashCode together" error; it also causes problems in Scala code which calls `.hashCode()`: ``` [error] /Users/joshrosen/Documents/spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala:247: type mismatch; [error] found : AttributeReference.this.metadata.type (with underlying type org.apache.spark.sql.types.Metadata) [error] required: ?{def hashCode(): ?} [error] Note that Metadata extends Any, not AnyRef. [error] Such types can participate in value classes, but instances [error] cannot appear in singleton types or in reference comparisons. [error] h = h * 37 + metadata.hashCode() [error] ^ [error] /Users/joshrosen/Documents/spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala:247: Int does not take parameters [error] h = h * 37 + metadata.hashCode() [error] ^ [error] two errors found [error] /Users/joshrosen/Documents/spark/sql/catalyst/src/main/scala/org/apache/spark/sql/types/Metadata.scala:41:13: You should implement equals and hashCode together ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org