Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5798#discussion_r29586723
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/package.scala
 ---
    @@ -77,4 +77,33 @@ package object expressions  {
         /** Uses the given row to store the output of the projection. */
         def target(row: MutableRow): MutableProjection
       }
    +
    +  /**
    +   * A utility classes for check the expression equality in semantic, not 
literally.
    +   */
    +  trait ExpressionEquals
    +
    +  private[this] class AttributeRefEquals(private val normalized: 
Expression)
    +    extends ExpressionEquals {
    +    override def equals(other: Any): Boolean = other match {
    +      case o: AttributeRefEquals => normalized == o.normalized
    +      case _ => false
    +    }
    +
    +    override def hashCode(): Int = normalized.hashCode()
    +  }
    +
    +  object ExpressionEquals {
    +    def apply(e: Expression): ExpressionEquals = new 
AttributeRefEquals(normalize(e))
    +
    +    protected def normalize(expr: Expression): Expression = 
expr.transformUp {
    +      case n: AttributeReference =>
    +        // We don't care about the name of AttributeReference in its 
semantic equality check
    +        new AttributeReference(null, n.dataType, n.nullable, 
n.metadata)(n.exprId, n.qualifiers)
    +    }
    +
    +    def semanticEquals(l: Expression, r: Expression): Boolean = {
    --- End diff --
    
    Seems it's never used?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to