You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by jiangxb1987 <gi...@git.apache.org> on 2016/10/17 03:32:03 UTC

[GitHub] spark pull request #2657: [SQL] Add type checking debugging functions

Github user jiangxb1987 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2657#discussion_r83573372
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/AttributeSet.scala ---
    @@ -17,19 +17,26 @@
     
     package org.apache.spark.sql.catalyst.expressions
     
    +import org.apache.spark.sql.catalyst.analysis.Star
    +
     protected class AttributeEquals(val a: Attribute) {
       override def hashCode() = a.exprId.hashCode()
    -  override def equals(other: Any) = other match {
    -    case otherReference: AttributeEquals => a.exprId == otherReference.a.exprId
    -    case otherAttribute => false
    +  override def equals(other: Any) = (a, other.asInstanceOf[AttributeEquals].a) match {
    +    case (a1: AttributeReference, a2: AttributeReference) => a1.exprId == a2.exprId
    +    case (a1, a2) => a1 == a2
       }
     }
     
     object AttributeSet {
    -  /** Constructs a new [[AttributeSet]] given a sequence of [[Attribute Attributes]]. */
    -  def apply(baseSet: Seq[Attribute]) = {
    -    new AttributeSet(baseSet.map(new AttributeEquals(_)).toSet)
    -  }
    +  def apply(a: Attribute) =
    +    new AttributeSet(Set(new AttributeEquals(a)))
    +
    +  /** Constructs a new [[AttributeSet]] given a sequence of [[Expression Expressions]]. */
    +  def apply(baseSet: Seq[Expression]) =
    +    new AttributeSet(
    +      baseSet
    +        .flatMap(_.references)
    --- End diff --
    
    Perhaps we should use `toAttribute` instead of `references` for `NamedExpression`? Otherwise the `AttributeSet.contains` method may return false result.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org