Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-32372

"Resolved attribute(s) XXX missing" after dudup conflict references

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.2.2, 2.3.4, 2.4.6, 3.0.0
    • 2.4.7, 3.0.1, 3.1.0
    • SQL
    • None

    Description

      // case class Person(id: Int, name: String, age: Int)
      
      sql("SELECT name, avg(age) as avg_age FROM person GROUP BY name").createOrReplaceTempView("person_a")
      sql("SELECT p1.name, p2.avg_age FROM person p1 JOIN person_a p2 ON p1.name = p2.name").createOrReplaceTempView("person_b")
      sql("SELECT * FROM person_a UNION SELECT * FROM person_b")   .createOrReplaceTempView("person_c")
      sql("SELECT p1.name, p2.avg_age FROM person_c p1 JOIN person_c p2 ON p1.name = p2.name").show
      

      error:

      [info]   Failed to analyze query: org.apache.spark.sql.AnalysisException: Resolved attribute(s) avg_age#235 missing from name#233,avg_age#231 in operator !Project [name#233, avg_age#235]. Attribute(s) with the same name appear in the operation: avg_age. Please check if the right attribute(s) are used.;;
      ...

      Attachments

        Activity

          People

            Ngone51 wuyi
            Ngone51 wuyi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: