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

order by fails when column is aliased and projection includes windowed aggregate

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.0
    • 2.0.0
    • SQL
    • None

    Description

      This statement fails in SPARK (works fine in ORACLE, DB2 ....)

      select r as c1, min ( s ) over () as c2 from
      ( select rnum r, sum ( cint ) s from certstring.tint group by rnum ) t
      order by r
      Error: org.apache.spark.sql.AnalysisException: cannot resolve 'r' given input columns c1, c2; line 3 pos 9
      SQLState: null
      ErrorCode: 0

      Forcing the aliased column name works around the defect

      select r as c1, min ( s ) over () as c2 from
      ( select rnum r, sum ( cint ) s from certstring.tint group by rnum ) t
      order by c1

      These work fine

      select r as c1, min ( s ) over () as c2 from
      ( select rnum r, sum ( cint ) s from certstring.tint group by rnum ) t
      order by c1

      select r as c1, s as c2 from
      ( select rnum r, sum ( cint ) s from certstring.tint group by rnum ) t
      order by r

      create table if not exists TINT ( RNUM int , CINT int )
      ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'
      STORED AS ORC ;

      Attachments

        Issue Links

          Activity

            People

              smilegator Xiao Li
              the6campbells N Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: