Github user lw-lin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16719#discussion_r98346999
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionSetSuite.scala
 ---
    @@ -32,6 +32,38 @@ class ExpressionSetSuite extends SparkFunSuite {
     
       val aAndBSet = AttributeSet(aUpper :: bUpper :: Nil)
     
    +  // An [AttributeReference] with almost the maximum hashcode, to make 
testing canonicalize rules
    +  // like `case GreaterThan(l, r) if l.hashcode > r.hashcode => 
GreaterThan(r, l)` easier
    +  val maxHash =
    +    Canonicalize.ignoreNamesTypes(
    +      AttributeReference("maxHash", IntegerType)(exprId =
    +        new ExprId(4, NamedExpression.jvmId) {
    +          // maxHash's hashcode is calculated based on this exprId's 
hashcode, so we set this
    +          // exprId's hashCode to this specific value to make sure 
maxHash's hashcode is almost
    +          // `Int.MaxValue`
    +          override def hashCode: Int = 826929706
    +          // We are implementing this equals() only because the 
style-checking rule "you should
    +          // implement equals and hashCode together" requires us to
    +          override def equals(obj: Any): Boolean = super.equals(obj)
    +        })).asInstanceOf[AttributeReference]
    +  assert(maxHash.hashCode() == Int.MaxValue - 1)
    +
    +  // An [AttributeReference] with almost the minimum hashcode, to make 
testing canonicalize rules
    +  // like `case GreaterThan(l, r) if l.hashcode > r.hashcode => 
GreaterThan(r, l)` easier
    +  val minHash =
    +    Canonicalize.ignoreNamesTypes(
    +      AttributeReference("minHash", IntegerType)(exprId =
    +        new ExprId(5, NamedExpression.jvmId) {
    +          // minHash's hashcode is calculated based on this exprId's 
hashcode, so we set this
    +          // exprId's hashCode to this specific value to make sure 
minHash's hashcode is almost
    +          // `Int.MinValue`
    +          override def hashCode: Int = 826929707
    --- End diff --
    
    updated, thanks!


---
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

Reply via email to