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

    https://github.com/apache/spark/pull/10630#discussion_r51059167
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -388,57 +445,18 @@ class Analyzer(
                 .map(_.asInstanceOf[NamedExpression])
             a.copy(aggregateExpressions = expanded)
     
    -      // Special handling for cases when self-join introduce duplicate 
expression ids.
    -      case j @ Join(left, right, _, _) if !j.selfJoinResolved =>
    -        val conflictingAttributes = 
left.outputSet.intersect(right.outputSet)
    -        logDebug(s"Conflicting attributes 
${conflictingAttributes.mkString(",")} in $j")
    -
    -        right.collect {
    -          // Handle base relations that might appear more than once.
    -          case oldVersion: MultiInstanceRelation
    -              if 
oldVersion.outputSet.intersect(conflictingAttributes).nonEmpty =>
    -            val newVersion = oldVersion.newInstance()
    -            (oldVersion, newVersion)
    -
    -          // Handle projects that create conflicting aliases.
    -          case oldVersion @ Project(projectList, _)
    -              if 
findAliases(projectList).intersect(conflictingAttributes).nonEmpty =>
    -            (oldVersion, oldVersion.copy(projectList = 
newAliases(projectList)))
    -
    -          case oldVersion @ Aggregate(_, aggregateExpressions, _)
    -              if 
findAliases(aggregateExpressions).intersect(conflictingAttributes).nonEmpty =>
    -            (oldVersion, oldVersion.copy(aggregateExpressions = 
newAliases(aggregateExpressions)))
    -
    -          case oldVersion: Generate
    -              if 
oldVersion.generatedSet.intersect(conflictingAttributes).nonEmpty =>
    -            val newOutput = oldVersion.generatorOutput.map(_.newInstance())
    -            (oldVersion, oldVersion.copy(generatorOutput = newOutput))
    -
    -          case oldVersion @ Window(_, windowExpressions, _, _, child)
    -              if 
AttributeSet(windowExpressions.map(_.toAttribute)).intersect(conflictingAttributes)
    -                .nonEmpty =>
    -            (oldVersion, oldVersion.copy(windowExpressions = 
newAliases(windowExpressions)))
    -        }
    -        // Only handle first case, others will be fixed on the next pass.
    -        .headOption match {
    -          case None =>
    -            /*
    -             * No result implies that there is a logical plan node that 
produces new references
    -             * that this rule cannot handle. When that is the case, there 
must be another rule
    -             * that resolves these conflicts. Otherwise, the analysis will 
fail.
    -             */
    -            j
    -          case Some((oldRelation, newRelation)) =>
    -            val attributeRewrites = 
AttributeMap(oldRelation.output.zip(newRelation.output))
    -            val newRight = right transformUp {
    -              case r if r == oldRelation => newRelation
    -            } transformUp {
    -              case other => other transformExpressions {
    -                case a: Attribute => attributeRewrites.get(a).getOrElse(a)
    -              }
    -            }
    -            j.copy(right = newRight)
    -        }
    +      // To resolve duplicate expression IDs for all the BinaryNode
    +      case b: BinaryNode if !b.duplicateResolved => b match {
    +        case j @ Join(left, right, _, _) =>
    +          j.copy(right = dedupRight(left, right))
    +        case i @ Intersect(left, right) =>
    +          i.copy(right = dedupRight(left, right))
    +        case e @ Except(left, right) =>
    +          e.copy(right = dedupRight(left, right))
    +        case cg: CoGroup =>
    --- End diff --
    
    In this case, it should work! Let me know if we should deduplicate the 
expression IDs for the other operators. 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