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

    https://github.com/apache/spark/pull/17100#discussion_r146211140
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
 ---
    @@ -270,12 +270,27 @@ trait CheckAnalysis extends PredicateHelper {
     
             operator match {
               case o if o.children.nonEmpty && o.missingInput.nonEmpty =>
    +            val resolver = plan.conf.resolver
    +            val attrsWithSameName = o.missingInput.filter(missing =>
    +              o.inputSet.exists(input => resolver(missing.name, 
input.name)))
    +            val repeatedNameHint = if (attrsWithSameName.nonEmpty) {
    +              val commonNames = attrsWithSameName.map(_.name).mkString(",")
    +              s"""|Please check attribute(s) `$commonNames`, they seem to 
appear in two
    +                  |different input operators, with the same 
name.""".stripMargin
    +            } else {
    +              ""
    +            }
    +
                 val missingAttributes = o.missingInput.mkString(",")
    -            val input = o.inputSet.mkString(",")
    +            val availableAttributes = o.inputSet.mkString(",")
     
                 failAnalysis(
    -              s"resolved attribute(s) $missingAttributes missing from 
$input " +
    -                s"in operator ${operator.simpleString}")
    +              s"""Some resolved attribute(s) are not present among the 
available attributes
    +                |for a query.
    +                |$missingAttributes is not in $availableAttributes.
    +                |$repeatedNameHint
    +                |The failed query was for operator
    +                |${operator.simpleString}""".stripMargin)
    --- End diff --
    
    Actually I agree with @viirya, the original error message is OK for me. If 
you really want to improve it, I think just adding `repeatedNameHint` at the 
end would be good enough:
    ```
    s"Resolved attribute(s) $missingAttributes missing from $input in operator 
${operator.simpleString}. $repeatedNameHint"
    ```
    What do you think?


---

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

Reply via email to